Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Your app isn't using AndroidX - Flutter doesn't allow me to generate apk

I developed an app in flutter with Visual Studio code on Mac. I ran the application without any kind of problem on IOS. I also installed it on a physical device and it works perfectly, but I have a problem generating the Android project study and its APK on with flutter.

Message:

flutter build appbundle
[!] Your app isn't using AndroidX.
    To avoid potential build failures, you can quickly migrate your app by following the
    steps on ...
Running Gradle task 'bundleRelease'...                                  
Note: Some input files use unchecked or unsafe operations.      
Running Gradle task 'bundleRelease'...                                                     Note: Recompile with -Xlint:unchecked for details.              
Running Gradle task 'bundleRelease'...                                                                                                        
Running Gradle task 'bundleRelease'... Done                       217,9s (!)
Gradle build failed to produce an .aab file. It's likely that this file was generated under
/Users/riccardo/Desktop/QuoteFlutter/quote/build, but the tool couldn't find it.
like image 679
riki Avatar asked Jan 28 '20 09:01

riki


People also ask

What is AndroidX flutter?

AndroidX is a redesigned library to make package names more clear. So from now on, the Android hierarchy will only be for Android default classes that come with the Android operating system. Other library/dependencies will be part of AndroidX and all new development will be updated in AndroidX.

How can I migrate my flutter project to AndroidX in VS code?

If you have a multi-root workspace, you can open any file in the Flutter project so the extension will find the correct files. Next, open the Command Palette ( Ctrl+Shift+P or Cmd+Shift+P on Mac) and search for 'androidx' to find the command "Convert Flutter Project to AndroidX".


4 Answers

in my own case my gradle.properties was missing. I Just created a new gradle.properties file inside the android folder, with the below parameter

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
like image 183
Godwin Avatar answered Oct 07 '22 11:10

Godwin


The error description clearly states that

Your app isn't using AndroidX. To avoid potential build failures, you can quickly migrate your app by following the steps on ...

How to resolve this?

Follow this detailed documentation.

like image 20
Darish Avatar answered Oct 07 '22 11:10

Darish


you should go to

YourAppName=> android => gradle.properties

inside gradle.properties add these two lines

android.useAndroidX=true
android.enableJetifier=true

dat should solve it.

like image 33
Ali Max Avatar answered Oct 07 '22 12:10

Ali Max


I had an old project using Firestore, that I was trying to open, and got this message. I could not find any easy way to fix it.

These were the steps I took to migrate it, hope it helps someone.

Create a new folder.

Then run this command in Terminal, in the folder:

flutter create --org com.yourdomain your_app_name

Copy the files from lib folder, (and any other modifications from android or ios folders).

Copy google-services.json to android\app folder.

Modify pubspec.yaml and copy the dependencies under dependencies:

Change android\app\build.gradle change version to:

minSdkVersion 21

Add the plugins needed in android\app\build.gradle:

apply plugin: 'com.google.gms.google-services'

In Android\build.gradle file: Add the dependency (with your version):

classpath 'com.google.gms:google-services:4.3.3' 
like image 2
live-love Avatar answered Oct 07 '22 11:10

live-love