When i run flutter run --release -v this command below error came
Caused by: java.lang.IllegalAccessError: Interface androidx.lifecycle.b implemented by class
com.mr.flutter.plugin.filepicker.FilePickerPlugin$LifeCycleObserver is inaccessible (declaration of 'com.mr.flutter.plugin.filepicker.FilePickerPlugin$LifeCycleObserver' appears in
/data/app/app.projects.xxx.mobile-1/base.apk)
My Gradle is
classpath 'com.android.tools.build:gradle:4.0.0' //4.0.1 //3.3.2 //3.5.3 //3.4.2
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
This worked for me.
Go to build.gradle file at android/gradle and downgrade to version 3.6.2 like shown below,
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
Answer taken from this thread.
I had similar issue, its related to gradle 4+ version i guess, i was able to resolve this by following below steps.
Add bellow line to app/proguard-rules.pro (if file not present create one.)
-keep class androidx.lifecycle.DefaultLifecycleObserver
Error from logcat, it was only having issue in release build. The emulator was working fine. -
03-12 07:41:32.281 22847 22847 E AndroidRuntime: java.lang.IllegalAccessError: Interface androidx.lifecycle.b implemented by class com.mr.flutter.plugin.filepicker.FilePickerPlugin$LifeCycleObserver is inaccessible (declaration of 'com.mr.flutter.plugin.filepicker.FilePickerPlugin$LifeCycleObserver' appears in base.apk)
Related Discussion/Issue can be found here -https://github.com/flutter/flutter/issues/58479
upgrade your grade classpath and distribution url to latest version.
also filepicker to latext version in pubspec.yaml
check if it works... if not then open android/gradle.properties and see if the following lines are there or not if not then add
android.useAndroidX=true
android.enableJetifier=true
check if following are there in your android/app/build.gradle or not
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
then flutter clean
then instead of directly running flutter run --release -v use the following its not related to your issue but it will cause another you will get something missingFile exception.
flutter build apk --debug
then flutter build apk --profile;
then flutter build apk --release;
Related
When I want to release a new flutter app bundle to the Playstore. I get this error:
"This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug."
I can't find any way to fix this. I'm new with flutter and releasing app's and getting a bit desperate...
Any help would be fantastic.
When I add "android.defaultConfig.ndk.debugSymbolLevel = 'FULL'" (on line 1) to the app/build.gradle as suggested in https://developer.android.com/studio/preview/features#native-crash-symbolization. I get This error in the Android studio terminal. I use this command "flutter build appbundle".
Error in Terminal:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\filip\AndroidStudioProjects\ehbo\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
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 3s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done 4,3s
Gradle task bundleRelease failed with exit code 1
Reproduce next steps and this warning will disapear
Go to
[YOUR_PROJECT]\build\app\intermediates\merged_native_libs\release\out\lib
note that 3 folders exist inside
arm64-v8a
armeabi-v7a
x86_64
Select this 3 folder and create a .zip file. Name doesn't matter.
[PLEASE NOTE THAT I HAVEN'T COMPRESSED THE ./lib FOLDER]
Upload this new *.zip file as Symbol File.
.
If talking about Flutter, looks like the Flutter team needs to change some source files for the NDK, because it does not see where from to generate debug symbols.
Here is an issue thread: https://github.com/flutter/flutter/issues/60240
Setup steps are so:
Pre-condition: Intall Android studio 4.1+ and Gradle 4.1+
Install NDK (Side by Side) in SDK manager
Write path to NDK in local.properties
Add in app/build.gradle (last line) android.buildTypes.release.ndk.debugSymbolLevel = 'FULL'
Before you can upload debug symbols files, you must be using Android Gradle plugin version 4.1 or higher.
Looks like it will come only with Android Studio 4.1, because I can only get Gradle 4.0.0 automatically now.
So I suggest you to return classic Play console and it will let you through :)
UPDATE:
So just use an updated Gradle and add NDK debug symbols to the build now
The Answer was given by Shakle will be not useful as per the following message on Play Console.
The old version of Play Console will be discontinued from November 2,
2020 You’re already using the new Play Console, so you don’t need to
do anything. A few features are going away if you want to check them
one last time.
It's just a warning, nothing else. Just go ahead.
If you don't want any warning, Go to this link and follow the steps:
https://support.google.com/googleplay/android-developer/answer/9848633?hl=en
You can use the new version of the play store as it is.
you can make these zip file by go to build\app\intermediates\merged_native_libs\release\out\lib inside your Flutter project
and compress the folders into symbols.zip, now upload it into the google play console
I had a similar problem.
What really helped me:
Make sure your Android Gradle plugin version is 4.1 or later.
Install NDK (Side by Side) in SDK manager.
Install CMake in SDK manager.
Add
ndkVersion <ndkVersion>
ndk {
debugSymbolLevel 'FULL'
}
to app/build.gradle
My final build.gradle:
...
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
versionCode 28
versionName "1.0.59"
ndkVersion "23.1.7779620"
ndk {
debugSymbolLevel 'FULL'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations {
compile.exclude group: 'com.google.zxing'
}
}
...
I hope this will help you and save you time
If you want to solve this warning error:
This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug. Make sure also to install CMake
This will happen if your gradle version is higher than 4.0
Place this code into your build.gradle file
android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.example.myproject'
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
ndk {
debugSymbolLevel 'FULL'
}
}
Instead of creating and uploading zip files, you can include the following to your app\build.gradle file:
buildTypes {
debug {
// This is just here for local testing and is optional.
firebaseCrashlytics {
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/app/intermediates/merged_native_libs/debug/out/lib")
}
ndk {
debugSymbolLevel 'SYMBOL_TABLE'
}
}
release {
// ..
firebaseCrashlytics { // Insert this
nativeSymbolUploadEnabled true
unstrippedNativeLibsDir file("build/app/intermediates/merged_native_libs/release/out/lib")
}
ndk {
// replace with 'FULL' if you need more info,
// but note that it will increase the file size of your appbundle dramatically.
debugSymbolLevel 'SYMBOL_TABLE'
}
}
}
Here is some documentation for reference:
https://firebase.google.com/docs/crashlytics/ndk-reports#upload-symbols-external-dependencies
And if you're unclear about how to set up automatic uploading of native symbols, try adding this:
buildTypes { ... } // Your build types from the above snippet.
tasks.whenTaskAdded { task ->
if (task.name.startsWith('assemble') && task.name != "assembleReleaseAndroidTest"
&& task.name != "assembleDebugAndroidTest") {
String taskName = "uploadCrashlyticsSymbolFile" + task.name.substring('assemble'.length())
task.finalizedBy taskName
doFirst {
println "Running Gradle task '$taskName'..."
}
}
}
More info for building gradle tasks here:
https://docs.gradle.org/current/userguide/tutorial_using_tasks.html
Also, ensure that you have NDK and CMAKE installed in your IDE's SDK Manager.
Hope that helps!
Simple approach, go to \build\app\intermediates\merged_native_libs\release\out\lib , you will find 3/4 folders , zip those , upload this ZIP from release option ( upload Symbol File ). Warning will be gone after bundle review.
For fixing it in the Visual Studio Code: you should first download
the NDK from the android's website.
Extract the zip file to a folder named ndk and place it under your - already installed - Android SDK folder. Like this: Android/sdk/ndk
Then open app/build.gradle.
Under the Android section. Add ndkPath property as follows: ndkPath = <ndk-dir>
app/build.gradle ndkPath property
At the end of app/build.gradle add android.buildTypes.release.ndk.debugSymbolLevel = 'full'
The next appbundle, built by flutter build appbundle command should not give any errors on the play store about native debug symbols.
a more thorough explanation is here
I just upgraded ndk from 21.4.7075529 to 22.1.7171670, and now I get the debug symbols.
I'm using com.android.tools.build:gradle:7.1.1 and React Natvive 0.69 BTW.
I have the exact same issue.
Possible solutions:
Use the Google classic Play console
Gradle 4.1 is now released with Android Studio 4.1
Could not get unknown property 'android' for project ':app' of type org.gradle.api.Project.
You have to add it in gradle.properties not build.gradle
I was able to get Flutter to build native debug symbols using Android Gradle Plugin (AGP) 4.1.0, installing corresponding NDK version and adding the appropriate config to android/app/build.gradle on macOS (but it should also work on Windows/Linux).
Optional: Run flutter build appbundle and take note of the .aab file size
Check what version of AGP you're using in android/build.gradle by looking in dependencies e.g. com.android.tools.build:gradle:4.1.0 is 4.1.0
Check which version of NDK you need. Assuming your AGP is 4.1.0 the NDK version you want to install is 21.1.6352462 (for other AGP versions check mappings here)
Install specific NDK version using Android Studio. Alternatively you can use sdkmanager and the CLI: $ANDROID_HOME/tools/bin/sdkmanager --install "ndk;21.1.6352462"
In android/app/build.gradle, under android.defaultConfig add ndk { debugSymbolLevel 'FULL' } aka set android.defaultConfig.ndk.debugSymbolLevel = 'FULL' as per this
Run flutter build appbundle. The .aab should now contain native debug symbols and be larger than the previous build in step 0
Troubleshooting: If you get any errors around CMake I didn't explicitly install it but you might need to, especially if you're using Windows, and you can do so using Android Studio.
screenshot
My issue was this:
This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug.
Fix successfully just upload native debug symbols from the image reference directory shown.
I'm on Windows 10 and I've created a Ionic 5.0.7 app with Capacitor 2.0.0.
I use this command to build app:
ionic build
After, I use this command:
npx cap sync
And, to finish, I use this command to open Android Studio:
npx cap open android
The first problem come during building on Android Studio:
org.gradle.api.reflect.ObjectInstantiationException: Could not create
an instance of type
com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
Caused by: org.gradle.api.reflect.ObjectInstantiationException: Could not create
an instance of type
com.novoda.release.internal.compat.gradle5_3.AndroidSoftwareComponentCompat_Gradle_5_3.
And...
java.lang.NoClassDefFoundError:
org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
Caused by: java.lang.NoClassDefFoundError:
org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
I've other random errors... It's weird...
Update
Check #Carl Pool 's answer
They fixed it in the new capacitor Version, no need to downgrade anymore
Old Answer
To fix this downgrade Gradle and Gradle plugin in Android Studio.
File -> Project Structure -> Project
If you keep the plugin to 4.0.0 it will require a minimum Gradle version of 6 so put it back to a lower version like 3.6.3
Version 6 of Gradle does not support LazyConfigurationUsageContext as mentionened by #NishaBhat, so use 5.6.4 instead.
This issue currently has a ticket on Github:
https://github.com/ionic-team/capacitor/issues/3003
This issue has been resolved in Capacitor version 2.1.2.
https://github.com/ionic-team/capacitor/issues/3003
Please update the Capacitor dependencies in package.json to version 2.1.2 and then in Android Studio click the button to sync the project with Gradle.
"#capacitor/android": "^2.1.2",
"#capacitor/core": "2.1.2",
Switch to using gradle version 5.6.4. That did the trick for me. LazyConfigurationUsageContext doesn't have support in gradle versions 6.0+
I was getting an error
Cause: org/gradle/api/internal/java/usagecontext/LazyConfigurationUsageContext
I solved by downgraded distributionUrl(gradle/wrapper/gradle-wrapper.properties) to https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
it will give an error if above 6+
Same problem.. had many issues:
Errors and how I solved:
Error 1. Gradle sync failed: Server returned HTTP response code: 403 for URL: http://services.gradle.org/distributions/gradle-5.6.4-all.zip
Solution - Downloaded the zip file and stored in on my local in the \android\gradle\wrapper folder.
Updated the distribution URL to: distributionUrl=./gradle-5.6.4-all.zip
Error 2. java.lang.NoClassDefFoundError & java.lang.NoClassDefFoundError:
Solution - Downloaded Gradle version 5.6.4 and updated the environment variables.
Error 3. Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
Updated as per the image below
i have not downgraded the gradle version 6.1.1 But what i did is that:
I removed these lines from build.gradle file
apply plugin: 'com.novoda.bintray-release' &
classpath 'com.novoda:bintray-release:0.9.1'
The Issue just gone like Boom !!
I think this Bintray Dependencies just conflicting behind the scene.
I am a beginner in Android. I am not able to resolve this error in Android Studio. Whenever I run my application this error occurs. How do I fix it?
Error: Unable to load class 'javax.xml.bind.JAXBException' Possible
causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync
project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build
processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of
Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
This is my solution
Update Gradle build tool version in project-level Gradle.
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
And then Android Studio will download and change your gradle-wrapper.properties file.
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
Sync project, everything is OK.
My problem was resolved when I changed the JDK for each of my Android SDKs:
Project Structure -> Platform Settings\SDKs -> Android API xx Platform -> Change "Java SDK" to 1.8
This resolved the problem;
Also change that the Project SDK to 1.8.
If the problem is not resolved, Please try to run IDE under JDK 8.
This might be too late but maybe some one needs to know the reason:
If you updated android studio to v4.2 and this happened, its because it is build in java 11
You have two options:
change JDK path manually in: Project Structure -> SDK Location
you should update your gradle setting use these two versions or above them:
classpath 'com.android.tools.build:gradle:4.0.0'
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip
I hope i could save some one's time
Also you can Update your gradle version in project level gradle
classpath 'com.android.tools.build:gradle:4.x.x'
and fixed this issue.
Just upgrade the Gradle version then it will fix the problem
install java 8, and set your JDK path with java 8
File- > Project structure. -> SDK location -> JDK Location
for mac os:
/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home
First check your gradle-wrapper.properties distributionUrl value and update with latest version of gradle.
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip
this is the one of the possible solutions, It was worked for me.
In app build file, add the options javaCompileOptions{ ... }
android {
…
defaultConfig {
…
//add this options
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
…
}
I have Just installed Android Studio Version 2.1 Preview 3 (AI-143.2682553)
When I run my project I get an error, it says:
Could not find com.android.tools.build:gradle:2.1.0-alpha3.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0-alpha3/gradle-2.1.0-alpha3.jar
When I look in the Jcenter repository it only has 2.1.0-alpha1 https://jcenter.bintray.com/com/android/tools/build/gradle/
So I get why it can't find alpha3, but when I change the build.gradle to 2.1.0-alpha1 it says:
"The projects is using an incompatible version of the android Gradle plugin.
To continue opening the project, the IDE will update the Android Gradle plugin to version 2.1.0-alpha3"
which doesn't seem to exist right ?
Android Plugin for Gradle version 1.5.0 does not support Instant Run. Please update to version 2.1.0-alpha3
I had the similar problem and I fixed it by update it in android studio,just like this!
after update ,I find out the changes of gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha3'
// classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
buildToolsVersion '24 rc1'//buildToolsVersion "23.0.2"
I had the similar issue with 2.1.0-alpha3 .. my project cannot be complied ..I used earlier version 2.1.0-alpha1 # http://tools.android.com/download/studio/builds/android-studio-2-1-preview-1
By uninstalling and installing older version.
Hope that may help.
I have an Android project that requires the Jsoup library. I've tried everything I can think of to get the jar shaded into the APK.. I just can't get it working. Logcat tells me:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: org.jsoup.Jsoup
Does anyone know how to include/shade a maven artifact into an APK with Android Studio?
I have found the answer. The trick is to append ":sources". See an example here: http://www.alonsoruibal.com/my-gradle-tips-and-tricks/
I have seen the same type of error every time someone else adds a library with Gradle. Build is usually successful but app crashes when it tries to use the new library. Running task clean with Gradle helps.