I have Android Studio build problem.
Build fails only when changing the minSdk=29 with follwing error.
( It's OK with minSdk=28 )
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.aaa"
minSdkVersion 29 // build fails with 29, it's OK with 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Fail messages on Android Studio build console
- Build: build failed
- Run build :
...
Caused by: com.android.tools.r8.utils.AbortException
- Andriod issues: (1 error)
Dex file with version '38' cannot be used with min sdk level '29'.
If anyone resolved this problem, please share your know-hows.
Thank you.
I came across this recently when updating a project for Android studio 3.5.3 to 3.6.3, however I manually changed gradle-wrapper.properties and the project's build.gradle before even opening the project.
In my case I was able to clean the build, delete the .gradle and .idea folders and rebuild without issue.
Edit: As stated in the comments, it is worthwhile to try a clean-rebuild first, rather than the "Scorched Earth" approach of deleting .gradle and .idea folders. Deleting them will take longer to recover from and blow away all your nice IDE settings!
This is because of latest gradle version :
classpath 'com.android.tools.build:gradle:3.5.3'
in Android 6.0 and lower android versions. In order to fix it you can downgrade the gradle version as follows :
classpath 'com.android.tools.build:gradle:3.5.1'
It will run on all android versions perfectly.
Related
i am new to flutter; i created a new project (nothing in code or files is changed) and when i try to run it, i get this error message:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not find aapt2-windows.jar (com.android.tools.build:aapt2:3.5.0-5435860).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.5.0-5435860/aapt2-3.5.0-5435860-windows.jar
can anyOne tell what's wrong? i used to run my apps and there was no issue; i don't know what happened! weird thing is when i click on the link i can download aapt2-3.5.0-5435860-windows.jar manually. idk why gradlew can't resolve it.
p.s: my gradle.build is the default file; nothing is changed.
you should try out the following two steps
Add mavenCentral() in build.gradle if missing
buildscript {
repositories {
mavenCentral()
jcenter()
}
update your minimum sdk version 16 to 21
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.jahid.testing_stackoverflow"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
This problem occurred when trying build android app, and off course it's related to gradle!
Solution 1, if you are using android studio and lucky!:
Open your flutter project android module as a separate project with a android studio.
As project open, android studio suggest you update gradle, click update and waiting for downloading to finish, run project again, it should work now.
Solution 2, if you are using android studio and don't lucky:
If for any reason in the previous solution android studio didn't show you recommended dialog, as you open android module as a separate project, click on project structure button and set versions manually.
Remember last version might not always working properly, so be wise!
Solution 3, if you are not using android studio:
You can also set these versions manually by going to following locations:
For setting android gradle plugin version go to YOUR_FLUTTER_PROJECT\android\build.gradle and changing:
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
For setting gradle version go to YOUR_FLUTTER_PROJECT\android\gradle\wrapper\gradle-wrapper.properties and changing:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
I'm working on Flutter app. I can run app in the android device successfully but try to make build (.apk) file and got below issues.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_twitter:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
/Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/ipatel/.gradle/caches/transforms-2/files-2.1/8f09fa5c6115de167b21b323f769edd9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5m 2s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 303.8s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin firebase_messaging...
The plugin firebase_messaging could not be built due to the issue above.
Below are project's stuffs
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.xxxx.eeee"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
> local.properties
sdk.dir=/Users/ipatel/Library/Android/sdk
flutter.sdk=/Users/ipatel/Documents/Amit/FlutterSetup/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.ver
My app is compatible with AndroidX and also tried with many solution but can't able to fix my issue.
I checked
- https://github.com/roughike/flutter_twitter_login/issues/29
- A failure occurred while executing com.android.build.gradle.internal.tasks
- flutter Error "Android dependency 'androidx.core:core' has different version" using flutter_local_notifications and location packages
and others.
Flutter Doctor Result:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.14.3 18D109, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (4 available)
build.gradle
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.xxxx.aaaa"
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
~PS : Let me know if you want more details from my end.
The issue is some library is not compatible or not using androidx while others are. Thanks to google for transferring all support lib to androidx now many libraries having conflicts like this and I mostly go to debug around which lib has an issue like commenting and uncommenting the lib from pubspec.
Assuming the flutter_twitter plugin was the issue.
As we can check that, that twitter plugin not using AndroidX link so we need to change it our self.
(all these changes needs to be changed in twitter plugin, not flutter project)
I think you can change the gradle.properties to use androidx and also compile version to 28
gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
add this two lines, change gradle classpath
classpath 'com.android.tools.build:gradle:3.5.3'
and compileSdkVersion 28 in flutter_twitter.
I am able to generate release build using that plugin.
Ohh yah you can find your cached version of plugin at /Users/parth.dave/.pub-cache/hosted/pub.dartlang.org/flutter_twitter_login-1.1.0/ something like this where you can update it. or either open android folder in androidstudio and studio will show you two projects app and twitter where you can update this things.
also sometimes it's better to open android project in android studio and update all things from which you might get errors before running flutter projects.
Problem is with Execution failed for task ':flutter_twitter:verifyReleaseResources'.
i found link for this issue
flutter_twitter_login/issue #12
Add this dependency in your pubspec.yaml file and let me know this working or not?
flutter_twitter_login:
git: git://github.com/eudangeld/flutter_twitter_login.git
Goto the android studio external libraries in the left side
--> select the library that cause this issue
--> then goto the android -> build.gradle and update the compileSdkVersion to 28
You need to update the compileSdkVersion of the flutter_twitter module to 28 :
1/ In your flutter project, locate your "android" folder and open it as an android project in Android Studio.
2/ Expand "Gradle Scripts" and wait for it to load.
3/ Locate "build.gradle (Module: flutter_twitter)"
4/ Modify the compileSdkVersion from 27->28.
5/ Save the changes.
My build worked after that.
The answer was here : https://github.com/flutter/flutter/issues/32595
thank you, it worked for me for device_id: ^0.1.3
plugin conflit with cloud_firestore: ^0.13.4+2
In your flutter project, locate your android folder and open it as an android project in Android Studio.
Expand Gradle Scripts and wait for it to load.
Locate build.gradle (Module: device_id)
Modify the compileSdkVersion from 27 -> 28.
Save the changes.
I faced a similar issue and here is how I fixed it by following this link.
In Android Studio (with your project open) right-click the android folder, and click "Flutter"->"Open Android Module in Android Studio". Select "Open in New Window"
In the new window, Wait for Gradle to finish the sync
Expand "Gradle Scripts"
Locate "build.gradle (Module: flutter_twitter)" or which so ever package is throwing the error
Modify the compileSdkVersion from 28->29 (or whatever is defined in your android/app/build.gradle file).
Save the changes and run flutter clean
Build the signed apk.
seems like your firebase_messaging library version does not support AndroidX support. Make sure you have updated version of this library.
dependencies:
firebase_messaging: ^6.0.9
I had the same problem before and it took almost a half day to find a solution.
My project compileSdkVersion was already 28 but in my case app-usage package compileSdkVersion was under 28 and i had to change it manually in
/home/"user"/.pub-cache/hosted/pub.dartlang.org/"package with problem"/android/build.gradle.
and it solved the problem.
I just updated Android Studio to 2.3. An error is shown that one of the cache files in the Gradle folder cannot be accessed, hence the Gradle sync failed. I tried restarting Android Studio and re-downloading the Gradle files but it doesn't help. Here is a picture of the error:
https://i.stack.imgur.com/iYwAE.png
You need to update your build tools to 25.0.0. Edit your build.gradle file in the main module:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
...
}
If that doesn't work, I recommend you to go back to Android Studio 2.2.3:
http://tools.android.com/download/studio/builds/android-studio-2-2-3
After upgrading gradle of my project (and library attached to it) from 2.1.3 -> 2.2.0 it doesn't build anymore and it says:
Error:Execution failed for task ':app:transformNative_libsWithStripDebugSymbolForDebug'.
java.lang.NullPointerException (no error message)
Anyone have a clue on why this is?
I found answer here:
https://stackoverflow.com/a/40117446/1088975
The point is to set both targetSdkVersion and compileSdkVersion to 22"
You need to change the following lines in build.gradle file:
android {
// SDK 24 worked for me - make sure you have the latest and update it accordingly.
compileSdkVersion 24
buildToolsVersion "24.0.2"
...
}
Maybe you can update the ndk version.
I update the ndk version from r10 to r13,and finally it worked.
You might want to check if the location of your NDK folder has any white space in it...if it has you can move your ndk folder to the c:\ drive and rebuild
Also, check the gradle versiom of your app and either upgrade or download later version, because some ndk versions do not support later gradle version
Failed to sync Gradle Project ‚HelloGlass‘
Error: Cause: failed to find target with hash string 'Google Inc.: Glass Development Kit Preview:19' in D:\Project\Android-SDK
Strangly, this error didn’t appear 3 days ago when I last built the project. I haven’t changed anything or used Android Studio since then.
These are the steps that I’ve tried to solve the issue:
restarted Android Studio and tried to build again
made sure that both gradle and my project use the same path for the Android SDK
made sure that I have the Google Glass Development Kit Installed in the SDK Manager (and all other packages for API 19 as well), also deleted and re-installed it
installed the latest Build Tools via the SDK Manager and consequently changed buildToolsVersion „23.0.1“ to „23.0.2“ in my gradle file
Replaced 'com.android.tools.build:gradle:2.0.0-alpha3' in my top-level gradle file with 'com.android.tools.build:gradle:2.0.0-alpha6' since this is the latest version
in gradle-wrapper.properties changed this line distributionUrl=https://services.gradle.org/distributions/gradle-2.8-all.zip
to this line:
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
and chose „use default gradle wrapper“ in the project options
cleared gradle caches in project/gradle and %HOME%/gradle
tried to build a new Google Glass Project from scratch in Android Studio – same problem
This is the relevant part of my gradle file:
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.helloglass"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
And my top-level gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
}
I don’t know what else to do. Any help is greatly appreciated!
I haven't found the reason for the problem, but after re-installing both Android Studio and Android SDK I can finally build the project.
Replace
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
with
compileSdkVersion 23
then rebuild the project, hope it will work