Build APK stuck at Task :app:checkReleaseAarMetadata - flutter

i am new in flutter.
When i run:
flutter apk build -v
it always stuck at
[+29946 ms] > Task :app:checkReleaseAarMetadata
I left it for almost an hour and nothing,
same happen when i run it on release or debug on my own device via usb debugging, but run perfectly on emulator on debug mode
any help would be appreciated, thanks

add the following line to android/build.gradle.try it and update is it fixed!
buildscript {
ext {
androidXCore = "1.7.0" // <-- Add this line
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}

Thanks, I found the solution.
In the end tried to clean install Android Studio including sdk, gradle, etc by deleting android studio related stuff on %APPDATA%, %USERPROFILE%, %LOCALAPPDATA%.
After that i build the apk again from vscode console and it work.
I think the error occurred because of missing stuff in gradle or error during sdk installation.

Related

How to find what Flutter packages requre SDK version #33?

When trying to deploy my Flutter app, I'm getting an error that says that the deployment requires SDK version #33.
How can I find what packages in the app require SDK #33?
R
unning Gradle task 'assembleDebug'...
Warning: The plugin url_launcher_android requires Android SDK version 33.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to D:\Ian\Documents\github\good_day\android\app\build.gradle:
android {
compileSdkVersion 33
...
}
android>app>build.gradle
compileSdkVersion 33
targetSdkVersion 33

How to enable Multidex inside flutter which is added to existing android project as module

I have and android project, which I added flutter on it as module,
In my original android app, multidex is enabled, but this do not help me, when running the app in debug it's working normally, but when creating a release apk or even debug apk the FlutterFragment is appearing as white, like the engine did not attach.
Things I notice, 'flutter run --release' will ask me to support multidex, and will not run, updating the minSdkVersion to 21 and enabling multidex in .android/app/build.gradle then again 'flutter run --release' works perfect, but this have no effect on the host app because it's under .android which automatically build, and ignored by the host app.
Also I tried to search for how to update minSdkVersion to 21 instead of 16, but references lead to change in the .android which have no effect.
Hey you can do two thing
Update your flutter SDK version by running command
flutter upgrade
The new version of flutter(2.10) multidex support automatically.
simply pass the --multidex flag to flutter build appbundle or flutter build apk and your app will support multidex.
2.In your app folder inside android [project_folder]/app/build.gradle and add following lines.
defaultConfig {
...
multiDexEnabled true
}
and
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
After a lot of investigation, the reason was related to something in the entry point, which needed to add project name, referring to this link

How to solve flutter.gradle and flutter.bat error?Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' && flutter.bat error

FAILURE: Build failed with an exception.
Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
The solution that worked for me was:
Delete pubspec.lock file
Do flutter pub get
Run the project
And it worked.
I was able to get around this by running with null safety turned off. See this article for details.
dart --no-sound-null-safety run
flutter run --no-sound-null-safety
Maybe this outdated but should help someone.
Yesterday I Just restarted my pc and got this issue. I tried to search for the solution to this problem but nothing works in my case.
Solution
Just delete your flutter folder (Flutter Source) and then reinstall it. Your problem will solve.
First flutter clean then flutter run worked for me. Ref - https://github.com/flutter/flutter/issues/75139. Thanks to https://github.com/darshankawar
Definitely, the problem is from ur Gradle settings.
For me, when I got the error, the problem was from the app/build.gradle file. there, my minSdkVersion was set to 23, so I just changed it to 21 and the error was solved. I will suggest u check your targetSdkVersion is set to 29 and compileSdkVersion is 29. I hope this help you too
In my case, I moved the project folder to D:, flutter clean, pub get and it runs
(In my case this error occurred after I upgrade Android Sdk to 31)
Go to AndroidManifest.xml and Set this to all Activities with
android:exported=true
if you build apk with --obfuscate, don't forget add a dot to head of your
--split-debug-info directory.
flutter build apk --obfuscate --split-debug-info=/projectfolder/debug
to
flutter build apk --obfuscate --split-debug-info=./debug
worked for me
I tried flutter clean, reinstalling SDK. Nothing worked.
My folder name was not correct. It was mvvm,provider test I changed it to mvvm_provider_test. Then it worked.
This error happened when I added a certain plugin. It turned out that the plugin required a minSdkVersion of 18. After I changed that, I did a flutter clean and after that, flutter pub get. So from this, I believe if you just added a recent plugin before you started facing this issue you look through the documentation of that plugin for installation info.
Also, after I did the above I had to restart my pc.
In case you're using flutter in command-line, just add -v which will run any flutter command in verbose mode. This should show you the origin of an error.
Like for me I was building with --split-debug-info and the folder I chose did not exist
In my case, what worked for me was removing the pubspec.lock and then doing a flutter pub get in my vscode command console, being in my project. Then modify the android\app\build.gradle file. inside the file I had compileSdkVersion 30 and update to version 31, being as follows compileSdkVersion 31
Download new Flutter SDK and update flutter path in your project,
And try again
After i upgraded to Android Sdk 31, this came for me. What solved was the answer suggested by #Elias Fazel above but before doing that, i first needed to edit my gradle.properties file. Added the following line :-
org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
This was suggested from here : How to fix the ''module java.base does not "opens java.io" to unnamed module '' error in Android Studio?
After this, i added this line to activity tag in AndroidManifest.xml & then it worked.
android:exported=true
Hope this helps.
In my case the issue was in Git
I have shifted to another branch which was merged and that causes the issue . then
checkout from the master to main problem solved .
For me, the problem was in my pubspec.yaml file. I made some changes to it got this error commented out those changes and now it works fine.
It's related with the Gradle, this issue comes when you have multiple Gradle versions in C:\Users\userName.gradle directory, the solution I made I deleted all directory files in .gradle directory, and restarted the IDE again with default gradle version who comes when you try to create the project at the first time 👉 (gradle-7.4-all.zip) this way works for me.
did face the same issue
"flutter pub cache clean" - running this command solved my issue
hope this becomes helpful
I did not find any solution so i did window again and all required software like flutter android studio etc.
and problem solved.

Flutter failed to compile apk: Finished with error: Gradle task assembleDebug failed with exit code 1

Flutter failed to compile an apk. I am not sure if this has something to do with AndroidX or something.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Finished with error: Gradle task assembleDebug failed with exit code 1
I ran flutter clean. I also ran flutter run -v. This is what happened: https://1drv.ms/t/s!An3OLJ7n0CjEku1SBrSABWab901z3Q
(I have used an external file locker because the stack trace is too large for the Stack Overflow editor).
This issue is similar to https://github.com/flutter/flutter/issues/30634
try follow steps:1. in gradle-wrapper.properties, downgrade from 5.1.1 to 4.10.2.2. int root/build.gradle, change android gradle version into 'com.android.tools.build:gradle:3.3.2'
Hope it is useful
It is common after migration to androidX.
If you followed recommended route from here:
https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
Try this:
Check with steps in "not recommended" way in above tutorial if every listed files is same as in your project, especially :
in root/android/gradle/wrapper/gradle-wrapper.properties set distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip (probably you have version 5.1.1 )
in root/android/build.gradle, set
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
check if in root/android/app/build.gradle SDK version is set to minimum 28 for:
compileSdkVersion 28 and targetSdkVersion 28
If you still get error then here is what helped me:
delete .gradle and .m2 folders from $HOME directory, as well with in app folders: root/android/.gradle and root/build
flutter doctor
flutter clean
flutter packages pub cache clean
if you changed (as me) app icon then run:
flutter packages pub run flutter_launcher_icons:main
it will render icons for app - without it print same error with gradle..
Invalidate caches in Android Studio "File" > "Invalidate Caches / Restart..."
If nothing from above works open android project as module
(you can do it by opening any file inside android folder for example manifest, then bar above code will shows with link to "Open for Editing in Android Studio", more here https://flutter.dev/docs/development/tools/android-studio )
Then click on gradle tab on the left and compile app - should show now more detailed error message.
Ok so here is your fix, open android sdk settings and uncheck Hide Obsolete Packages and in sdk tools, Check Android SDK Tools (Obsolete) than click ok/apply. It will download old SDK. Than Restart the IDE, Run default flutter program on emulator. This error occurs because flutter isn't compatible with latest Android SDK so you have yo manually install old SDK in Android studio.
Try running "flutter clean" in the project. If it doesn't work, please paste the output after running "flutter run -v".
In the debug mode applications worked well, but when I tried to build a release version, it had this error.
"Flutter doctor -v" was ok.
Made flutter clean.
Checked all AndroidX recommendations, used all latest versions of packages.
Checked android/app/fourpillarsappru1.keystore settings.
Finally the decision was use build in in Android Studio commands instead of command line "flutter build apk".
So, the decision in my case was:
Open build.gradle for editing in Android Studio
Choose Build / Generate Signed Bundle/APK
I had the same problem and solve the error by running flutter doctor --android-licenses and accept all licenses agreement.
I hope it will help
The Solution that works for me and makes the most sense CLEAN CACHE
Enter Command below
--> flutter packages pub cache clean
Downgrading the build gradle version in gradle-wrapper.properties from 5.1.1 to 4.10.2 worked for me.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Dependencies in project: build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.0.1'
}
module: build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def versionPropertiesFile = rootProject.file("../version.properties")
def versionProperties = new Properties()
versionProperties.load(new FileInputStream(versionPropertiesFile))
def flutterVersionCode = versionProperties.getProperty('flutter.versionCode')
def flutterVersionName = versionProperties.getProperty('flutter.versionName')
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.lok.sewa"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
Try checking your key.properties file. There might be error in key path, keyAlias or passwords. The error by key errors is not traceable.
This solution worked for me
It is android problems only so
Open in Android Studio
and pick Flutter->Open module in Android Studio
menu Build->Build Bundle(s) / APKs->Build Bundles.
My code contain keystore info in build.gradle,but we don't have keystore file in our git repository.My colleague uploaded his local keystore file and the problem was solved.
I just simply fixed it by changing the minSdkVersion . Just try minSdkVersion 19 or 21. It will fix.
compileSdkVersion 29
minSdkVersion 19
targetSdkVersion 29

image_picker plugin causes build error for Android

I installed the image_picker plugin into my project, and it works with iOS, But now the Android build crashes with the error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
Any idea why the Android build crashes when using this plugin?
You have to enable multidex in your build.gradle file :
android {
.
.
.
defaultConfig {
minSdkVersion //your minimum SDK version
targetSdkVersion //your target SDK version
multiDexEnabled true // this is what you should add
}
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
I had to roll back my Firestore plugin to 0.7.4 to fix this: answer found here.
I do also have multidex enabled as other answers suggested - this fixed an earlier crash I encountered with Firebase plugins.