How to migrate to AndroidX in Android-Studio latest version? - flutter

When i click on migrate to androidX, it ask for backup as a zip file. While i click on (ok), after that nothing happens. I can't find from where i can refactor it.

In the android folder in your flutter app, there is gradle.properties file, include this
android.useAndroidX=true
then you're good to go

Related

New Flutter project only has .idea folder and .iml file

this is my first time actually posting a question on here, despite already having frequently browsed this wonderful platform for answers before, so apologies if there is something missing or if it isn't too clear.
I'm somewhat new to flutter and android studio, and am currently wondering why when creating a new flutter project on android studio, only the .idea folder and .iml file appear under the main folder [https://i.imgur.com/6YMkkv3.png]
I've also run flutter doctor and while it did show 2 issues, I'm almost positive they were already present before and did not pose a problem [https://i.imgur.com/1IshqrQ.pngl]
Please follow the following guide Set up an editor to set up your editor to work with Flutter, and then Test drive to create a Flutter project.
.idea is a folder that is created by Intellij IDEA and contains metadata about your workspace like settings, run configs etc..
.iml contains module metadata.
For the chrome issue, try running
flutter config --enable-web

Problem Import Flutter Project to Android Studio

I tried to import flutter project from my pc to the android studio and got this error.
I already read the link that they give to me but I still don't understand. A little help please, or how do I import flutter project correctly?
The error
The project is not Gradle based can be because bulid.gradle and settings.gradle are not in the IDE project directory,
Try this
Open that other folder as an Android Studio Project and let it download other dependencies and file or you can create new flutter project and check the file generated with yours and try to add the file not in your own from the new flutter project you created.
This will solve the issue
from which version/tool you imported the project?. This is normally happed because of gradle-wrapper issues. Please check the link.
https://quick-adviser.com/how-can-we-solve-project-is-not-a-gradle-based-project/
I usually solve this by File -> Repair IDE

FLUTTER Android Studio BUMBLEBEE: Generating signed bundle requires you to update the Android Gradle plugin to version 3.2.0 or higher

When I try to build > generate signed bundle
AS complains:
Generating signed bundle requires you to update the Android Gradle
plugin to version 3.2.0 or higher
If I click on Close this dialog and update the plugin
A further dialog appears (AS Bumblebee) titled update the Android Gradle plugin If I hit OK, the dialog vanishes, nothing happens, and I get the same complaint when I try to build a signed app bundle again.
This is really frustrating because I can't upload an app with Googlemaps without signing it. That's my whole app!
OK well similar problems have been answered a few times on StackOverflow, but some of the solutions have become antiquated other solutions don't seem relevant:
I can see no way to update Gradle through File > project structure in Android Studio Bumblebee.
If I try and update Gradle manually in android/build.gradle, well it already has gradle 7.03, which is way above 3.2.0. Although Gradle and Android Studio's Gradle plugin may have different version numbers. See the code snippet below.
I've tried using Android Studio's search box with 'update Gradle plugin' to no effect.
I've hunted around Preferences > SDK tools, but no mention of a gradle plugin.
Instead of using an app bundle I've tried generating a signed APK, but that has problems too, and the file is larger, so no easy solution.
This is the relevant part of my android/build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.5'
}
FURTHER investigation, gradle-wrapper.properties contains this:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Which is a different version number to my android/build.gradle:
classpath 'com.android.tools.build:gradle:7.0.3'
I'm not sure why they have different numbers.
This is the last hurdle for one app, and a roadblock in another, please help. I'm totally lost, I've begun to think maybe a Kotlin plugin upgrade has caused havoc somehow.
UPDATE
I've reported the issue to Google, via AS's help menu, and in doing so the report said this...
AS: Bumblebee | 2021.1.1; Kotlin plugin:
211-1.6.10-release-923-AS7442.40; Android Gradle Plugin: (plugin
information not found); Gradle: (gradle version information not
found); Gradle JDK: version 11.0.11; NDK: from local.properties: (not
specified), latest from SDK: (not found); LLDB: pinned revision 3.1
not found, latest from SDK: (package not found); CMake: from
local.properties: (not specified), latest from SDK: (not found), from
PATH: (not found)
That's a lot of things missing! Both gradle and the gradle plugin. I've tried creating a fresh project in AS Bumblebee then asking for a signed bundle but get the same complaint, so it's not because the projects have taken a while.
Any solutions are appreciated. I thought you just downloaded Android Studio and it was all good to go... sigh.
UPDATE attempted the solution offered below, but I do not appear to have a Gradle location set, as per picture...
Finaly solve this problem.
I trid all that way mentioned in the question and stell that dump error
it doesn't look logical. but its work for me.
I closed project in android studio then open android folder at my project folder in new a android studio window,
like this below
then it take long time for downloading, analyzing, or... something,
you can see the layout is not same as main project ....
also build menu has more options...
after that tried to build app bundle and everything is good.
I think generating app bundles is not possible in main project file. we need to switch to android folder and generating it.
after all these I searched youtube generate app bundle android studio flutter
https://www.youtube.com/watch?v=g0GNuoCOtaQ
in this building app bundle in another way that doesn't have these headaches
Well in the end I solved it. In the left hand project files pane I right-clicked on Android > Open in Android Studio, Gradle then took a long time reindexing the project and offered to update the project's Gradle version, which this time it did successfully. HALLEYUH!
I seldom push out signed apps, so I'd forgotten the process for doing this, and the fact that the AS Flutter plugin offered me the option of Tools > build signed app bundle within the plugin led me away from how I've successfully attained a signed app in the past.
I think really the Flutter team shouldn't offer this option if it's not going to work reliably, but the solution is to do it the old way. Change the IDE back into what I presume is 'Java app' view, and be patient while AS runs around fetching gradle and Android SDK updates, reindexing. Then seek Build > signed app bundle from there.
Thanks everybody for your attention, and apologies for wasting energies. x Sam
In Settings, 'Build, Execution, Deployment', 'Build Tools', 'Gradle' I had a 'Use Gradle From' set to a 'Specified Location' and it was breaking the build. It must have come from some previous version. I changed it to "'gradle-wrapper.properties' file" and everything went fine.
I also noted a much larger 'aab' file in Bumblebee. I know I added stuff, but not 8 megabytes worth. It was only code, and maybe a thousand lines.

Why can't migrate my flutter project to androidx?

I have a flutter project I want to migrate to AndroidX. The docs say I should open Android Studio and click "Sync Project with Gradle Files" but that option is disabled for me as seen in the following picture:
how can I enable this option and migrate to AndroidX?
Open Android Studio.
Select Open an existing Android Studio Project.
Open the android directory within your app.
Wait until the project has been synced successfully. (This happens automatically once you open the project, but if it doesn’t, select Sync Project with Gradle Files from the File menu).
If you are asked to backup the project before proceeding, check Backup project as Zip file, then click Migrate. Lastly, save the zip file in your location of preference.
The refactoring preview shows the list of changes. Finally, click Do Refactor:
That is it! You successfully migrated your project to AndroidX.
Select Migrate to AndroidX from the Refactor menu.

Error: Entrypoint isn't within the current project

Unable to run flutter from Android Studio not detecting flutter project its shows Error: Entry point isn't within the current project
Every time restart android studio same error message shows
Delete the .idea folder inside the root of the flutter project and restart Android Studio.
Refer to this question: What is the .idea folder? and make your decision if it's safe or not to delete .idea folder.
Click on File-> Project Structure -> Module then add root folder of
your project then it will detect its a flutter app and then build and
work
its work for me
Reference: https://github.com/flutter/flutter-intellij/issues/2307
1) make sure flutter and dart sdk paths are properly configured from
File-> Settings..->Languages and Frameworks
as well as make sure Dart support is enabled for project module from Dart Option
2) at the end select File->Invalid caches and restart
3) so after 2nd step you may get in File->Project Structure.. option from there Select Modules then just simply add only root folder path of your flutter project and repeat just above 2nd step
for me this worked
Syncing your project with gradle files will solve it:
You can sync the files with Gradle, within the File menu.
Else You can re-include the files/project root folder inside the File Menu.
File -> Project Structure -> Module
And then add the root folder of the project(with + icon), then it will detect that it's a flutter app again, and then build and work again.
Try delete .idea folder inside project folder and Invalidate & Restart Android Studio.
For me my project was missing the pubspec.yaml file, it was deleted by mistake , instead of warning about the missing file , I got this error
This problem happened to me
I solved it this way
Go to the Android Studio track
I have this way
C:\Users\mustafamaxL\.AndroidStudio4.0\system
Remove folder (caches)
Then, start Android Studio again
If your ios, android, or lib folders are missing, it typically means there is something wrong with your project structure.
To fix it, delete the .idea folder in the root of your project and then restart Android Studio. If you're using a Mac, you can display the hidden .idea folder by pressing Command+Shift+Dot in Finder.
The .idea folder will be automatically regenerated and everything should be back where it belongs.
See this post for the original solution.
Click Content Root Close Icon and Remove Android Folder.
Fix it to me.
I faced the same issue today and tried other solutions here but it wasn't worked at all.
In my case I deleted three folders that is android, ios, and .idea from project directory, then restarted android studio and finally I gave this command in Android Studio's Terminal.flutter create . to create appropriate directories (i.e., android & ios).
Now it is working fine.
Note: Before deleting the android / ios directory please make a backup of these directories only if you previously gave native code in android / ios directory.
Hope this solution will helpful if others will not work.
The .idea folder will also be deleted on Linux. When Andriod Studio opens, click terminal at the bottom in Android Studio. Then type remove -r .idea/ in the terminal and press enter. After deleting, close and restart Android Studio.
You might need to update the Gradle version. Or change the minimum android SDK version.
Here is worked for me:
Update Gradle / minSdkVersion version
Reopen the project but at the directory user/StudioProjects/yourFlutterApp/android.
After it is opened it will load some packages (see right bottom), which will take some time.
It will ask you to update the Gradle version (right-left corner) or go under File>Project Structure Project you can set a higher Gradle version and under Modules variables of your build
Now you can sync your project with Gradle files
After configuration, you might need to restart your project with File>Invalid Caches/Restart....
I have created 2 folders inside lib's folder for my *pages* and *widgets*.
Getting the main.dart file back to the **lib folder** will do the trick
I'm currently in Android Studio Electric Eel.
I've done all of the suggested solutions above, but nothing works.
Turns out the project is not detected as a Flutter project. So what I do to resolve this issue is to remove gradle-related files from the root folder:
build.gradle
gradlew
gradlew.bat
gradle/