java.lang.NoClassDefFoundError: android/graphics/drawable/Icon - android

So far I got this error only for one user, who uses a rooted phone (SM-G900R7 Android 4.4.2). The error is like this:
Fatal Exception: java.lang.NoClassDefFoundError: android/graphics/drawable/Icon
at java.lang.Class.getDeclaredMethods(Class.java)
at java.lang.Class.getDeclaredMethods(Class.java:656)
at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
at android.view.ViewDebug.dumpView(ViewDebug.java:900)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:870)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dump(ViewDebug.java:793)
at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
at android.view.IWindow$Stub.onTransact(IWindow.java:65)
at android.os.Binder.execTransact(Binder.java:404)
at dalvik.system.NativeStart.run(NativeStart.java)
I never use android.graphics.drawable.Icon in my code, all usages are from android.support.v4.graphics.drawable.IconCompat and I also never use that class in my code...
Btw my support library is version 26.0.0, my minSdkVersion is 15 targetSdkVersion is 26.
Thanks

Update
The issue is fixed in support library 27.0.0. If you update don't forget to change compileSdkVersion 27 as well.
What is happening?
Samsung devices with Android 4.4 crash like this when classes extending View define methods which return or take parameters of types that are not on classpath.
Starting with support library version 25.4.0 AppCompatImageView and AppCompatImageButton incorrectly overrides setImageIcon(Icon) method. Since Icon class was introduced in API 23 the app crashes on Samsung devices with API 19.
Similar thing happens when you try to override View.onApplyWindowInsets(WindowInsets).
Workaround for support library 26.1.0
Until this gets fixed in an official manner, If you're stuck with an older version of the support library, I made a modified version of appcompat-v7 where all traces of setImageIcon methods are removed. This means it won't crash on a Samsung with Android 4.4.
Put this at the bottom of your app's build.gradle:
repositories {
maven { url "https://dl.bintray.com/consp1racy/maven" }
}
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name == 'appcompat-v7') {
details.useTarget 'net.xpece.android:support-appcompat-v7-fixed:26.1.0-1'
}
}
}
This code will replace appcompat-v7 dependency with the described modified artifact.
Currently the only supported version of the fix is 26.1.0.
Warning: Understand the code before copy-pasting, and always exercise caution when getting code from unknown sources!

This issue was resolved in support library 27.0.0:
Android Gradle Plugin 3.x:
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
Android Gradle Plugin 2.x:
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
Note that you will also need to compile against SDK level 27.

This crash related to 25.4.0 version of support library.
Use 25.3.1 version.
Replace
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
With:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'

There are 2 options :
Have you changed the support library version ? this is quite classic library issue when the resources sometimes aren't 'saved' with the same name, or at all. Its not you, its google. Try to use support lib 25, and see if this error still occurs.
Try to clean the project and rebuild. Maybe you're kept with some old library versions in your build folder, and when you build your project it takes old values from it.

Related

Google sign in button error in android studio

Situation:
I am trying to add Google SignIn button to my project using the Custom Google SignIn Button library like the one shown above:
Here is my build.gradle file:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
compile 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Problem:
I get the following error:
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.shobhitpuri.custombuttons:google-signin:1.0.0]
C:\Users\durga rao.gradle\caches\transforms-1\files-1.1\google-signin-1.0.0.aar\4fa7da22804ff19ac92142afd0b85e2b\AndroidManifest.xml as the library might be using APIs not available in 15 Suggestion: use a compatible library with a minSdk of at most 15,or increase this project's minSdk version to at least 16, or use tools:overrideLibrary="com.shobhitpuri.custombuttons" to force usage (may lead to runtime failures)
Initial solution:
From the tags on the question, it looks like you are using Android Studio 3.0, which uses Gradle 3.0 and above. One of the breaking changes with Gradle 3.0 plugin based on Use the new dependency configurations
documentation is that the compile keyword has been replaced with implementation. So for adding Custom Google SignIn Button library, instead of compile keyword with the library use:
implementation 'com.shobhitpuri.custombuttons:google-signin:1.0.0'
Update:
Based on the error you mentioned, it seems in your project's build.gradle, your minSdkVersion is set to 15. The Custom Google SignIn Button library supports minSdkVersion of 16 since based on Platform Version Distribution Chart, 99.3% of the Android devices in the world are running API 16 and above. Changing your projects minSdkVersion to 16 should solve the issue. Hope this helps.
Disclaimer: I am the author of the library. Please let me know if you face any issues. Would be happy to help.

error: resource android:attr/fontVariationSettings not found

Warning:The android.dexOptions.incremental property is deprecated
and it has no effect on the build process.
/home/midhilaj/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/be3106efb0df111fe5a3f7b356dd070b/res/values/values.xml
Error:(246, 5) error: resource android:attr/fontVariationSettings not
found.
/project/bkup/7_march_2018/hyshoper/milla/build/intermediates/incremental/mergeDebugAndroidTestResources/merged.dir/values/values.xml
Error:(246, 5) error: resource android:attr/ttcIndex not found.
Error:(269) resource android:attr/ttcIndex not found. Error:(269)
resource android:attr/fontVariationSettings not found.
Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:failed linking references.
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error:
check logs for details Error:Execution failed for task
':milla:processDebugAndroidTestResources'.
Failed to execute aapt Information:9 errors Information:BUILD FAILED in 2s Information:1 warning Information:See complete output in console
How to solve this issue?
my dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'de.hdodenhof:circleimageview:2.2.0'
compile('com.alibaba.android:ultraviewpager:1.0.6.1#aar') {
transitive = true
}
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'com.synnapps:carouselview:0.1.4'
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
implementation 'com.muddzdev:styleabletoast:2.0.2'
compile 'javax.annotation:javax.annotation-api:1.2'
compile 'me.grantland:autofittextview:0.2.+'
// base library
//slider
compile 'com.ss.bannerslider:bannerslider:1.8.0'
//noinspection GradleCompatible
compile 'jp.wasabeef:recyclerview-animators:2.2.7'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.satyan:sugar:1.4'
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:percent:26.1.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.satyan:sugar:1.4'
compile 'jp.wasabeef:recyclerview-animators:2.2.6'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
compile 'com.afollestad.material-dialogs:core:0.9.4.2'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.android.gms:play-services-auth:9.8.0'
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-config:9.8.0'
compile 'com.google.firebase:firebase-crash:9.8.0'
compile 'com.google.firebase:firebase-invites:9.8.0'
compile 'com.google.firebase:firebase-storage:9.8.0'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'at.blogc:expandabletextview:1.0.3'
compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.+'
compile 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
}
try to change the compileSdkVersion to:
compileSdkVersion 28
fontVariationSettings added in api level 28. Api doc here
This is caused by an incompatibility with the android support library that changed to version 28. I solved the problem by forcing the build to use a lower support library. //like build gradle
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
My project built successfully immediately after I changed this. Hope this might help you too. I lost a day of development because of this!.
For those that must keep compileSdkVersion 27 and are unable to upgrade to androidx yet, you must not upgrade to (or over) the versions of dependencies in the following links. These links are where the breaking change was introduced. You must find an earlier version that doesn't use androidx.
https://firebase.google.com/support/release-notes/android#update_-_june_17_2019
https://developers.google.com/android/guides/releases#june_17_2019
For instance, the following are compatible with compileSdkVersion 27:
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
}
The following will break with compileSdkVersion 27 and are only compatible with compileSdkVersion 28:
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
}
If you are updating to v28
change the compileSdkVersion to compileSdkVersion 28
I solve this problem with the line below:
cordova plugin add cordova-android-support-gradle-release --save
After that the compile was succesful.
For native Android apps (not Cordova) solution for me is:
Was:
implementation 'com.android.support:support-v13:+'
Now:
implementation 'com.android.support:support-v13:27.1.1'
#All the issue is because of the latest major breaking changes in the google play service and firebase June 17, 2019 release.
If you are on Ionic or Cordova project. Please go through all the plugins where it has dependency google play service and firebase service with + mark
Example:
In my firebase cordova integration I had
com.google.firebase:firebase-core:+
com.google.firebase:firebase-messaging:+
So the plus always downloading the latest release which was causing error. Change + with version number as per the March 15, 2019 release https://developers.google.com/android/guides/releases
Make sure to replace + symbols with actual version in build.gradle file of cordova library
Another fix for Ionic 3 devs is to create build-extras.gradle
inside platforms/android and put following
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
Note that build-extras.gradle is not the same as build.gradle
after upgrading to Android 3.4.2 and FTC SDK5.2. I got these errors when building APK:
Android resource linking failed
C:\Users\idsid\FTC\SkyStone\TeamCode\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1205: error: resource android:attr/fontVariationSettings not found.
C:\Users\idsid\FTC\SkyStone\TeamCode\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1206: error: resource android:attr/ttcIndex not found.
error: failed linking references.
What I did is to add following section to project build gradle and problem is fixed.
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion '29.0.2'
}
}
}
}
Good luck.
I encountered this error in a flutter project and all I had to do update my compileSdkVersion to 28.
STEPS:
In your app level build.gradle file, search for compileSdkVersion
Check the current version
If less than 28, update it to 28
As zyc zyc stated above, the property fontVariationSettings was added in API level 28.
You can also read more about it here
Usually it's because of sdk versions and/or dependencies.
For Cordova developers, put your dependencies settings in "project.properties" file under CORDOVA_PROJECT_ROOT/platforms/android/ folder, like this:
target=android-26
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:26.1.0
cordova.gradle.include.2=cordova-plugin-googlemaps/app-tbxml-android.gradle
cordova.system.library.3=com.android.support:support-core-utils:26.1.0
cordova.system.library.4=com.google.android.gms:play-services-maps:15.0.0
cordova.system.library.5=com.google.android.gms:play-services-location:15.0.0
So if you use CLI "cordova build", it will overwrite the dependencies section:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
/* section being overwritten by cordova, referencing project.properties */
...
// SUB-PROJECT DEPENDENCIES END
}
If you are using proper libraries and its versions in project.properties, you should be fine.
This was a pain in the ass for me! Especially after updating to Android Studio 3.2.1 and Gradle 4.6 (for Gradle developers).
I think there is more than one factor that could cause such a build exception. For me, I had the following lines of code in my gradle.properties file (using SDK version 27):
android.useAndroidX=true
android.enableJetifier=true
AndroidX is the alternative to Android's default Support Library and should be used when compiling and targeting SDK version 28 (API 28). Before the updating Android Studio and Gradle, I had added the lines above in preparation to eventually fully migrate to AndroidX to use SDK version 28 and the build ran successfully. It was only after the update that I received an error similar to that above:
error: resource android:attr/fontVariationSettings not found
Hope this helps.
If you have stumbled upon this problem due to getting this error recently out of nowhere in react native- this is due to the latest BREAKING CHANGE in Google Play service and Firebase. Check this thread first -
https://github.com/facebook/react-native/issues/25293
And solution would mostly be like this -
https://github.com/facebook/react-native/issues/25293#issuecomment-503045776
I had the same error, but don't know why it appeared. After searching solution I migrated project to AndroidX (Refactor -> Migrate to AndroidX...) and then manually changed whole classes imports etc. and in layout files too (RecyclerViews, ConstraintLayouts, Toolbars etc.).
I changed also compileSdkVersion and targetSdkVersion to 28 version and whole project/application works fine.
If anybody has this error using phonegap or cordova with the cordova-plugin-fcm-ng or cordova-plugin-fcm plugin, the solution that worked for me is creating the extra config file for gradle "build-extras.gradle" in the \platforms\android\app folder, and putting the following lines in it
configurations.all {
resolutionStrategy {
force 'com.google.firebase:firebase-messaging:18.0.0'
force 'com.google.firebase:firebase-core:16.0.8'
}
}
I found this solution reading this page https://github.com/facebook/react-native/issues/25371, in particular comment of shreyakupadhyay on 30/07/19 and consulting https://developers.google.com/android/guides/releases#may_07_2019 about last libraries version.
error: resource android:attr/fontVariationSettings not found
I got this error when i added ButterKnife library but upgrading compileSdkVersion to 28 and targetSdk to 28 solved my issue.
I had this problem suddenly happening after trying to pull a dependency depending on sdk 28 (firebase crashlytics), but then decided to revert back the changes.
I tried automatic refactor Migrate to Androidx (which do half the job), added android.useAndroidX=true in gradle.properties at some points, and make the project work again.
But it was a lot of changes before a delivery. There was no way to have the project compile again with SDK 27. I git clean -fd, removed $HOME/.gradle, and kept seeing androidx in ./gradlew :app:dependencies
I ended up removing ~/.AndroidStudio3.5/ too (I'm on 3.5.3). This makes the project compile again, and I discovered the dark mode...
For Ionic 3 devs. I had to update the platforms/android/project.properties file ONLY on:
cordova.system.library.2
to be v4:28.0.0+ otherwise the build kept failing.
After doing so, my project.properties file contents are shown below:
target=android-26
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.android.support:support-v4:28.0.0+
cordova.system.library.3=com.android.support:support-v4:+
cordova.system.library.4=com.android.support:support-v4:25.+
cordova.system.library.5=com.android.support:appcompat-v7:25.+
cordova.gradle.include.1=cordova-plugin-googlemaps/starter-tbxml-android.gradle
cordova.system.library.6=com.google.android.gms:play-services-maps:15.0.1
cordova.system.library.7=com.google.android.gms:play-services-location:15.0.1
cordova.system.library.8=com.android.support:support-core-utils:26.1.0
cordova.system.library.9=com.squareup.okhttp3:okhttp-urlconnection:3.10.0
cordova.gradle.include.2=cordova-android-support-gradle-release/pasma-cordova-android-support-gradle-release.gradle
I hope this helps someone. Was a real problem for me.
For me : My external library was using this attributes attr/fontVariationSettings and attr/ttcIndex so I downgrade my library version and sync project . everything fine
So now :
compileSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
and for future readers that library was google's easypermission.
implementation 'pub.devrel:easypermissions:2.0.0'
This lib is using sdkversion 28, I have to downgrade to 1.3.0
I have soled the problem by changing target android version to 28 in project.properties (target=android-28) and installed cordova-plugin-androidx and cordova-plugin-androidx-adapter.
I just got this AndroidX error again after I fixed it a year ago. I am using Flutter.
I was able to make releases using Flutter 1.7.8+hotfix.4, then recently I updated Flutter to version 1.17.4 and then I could not compile a release build any more. Debug builds worked just fine.
TLDR:
This time it was a package using another package that was not updated proper for AndroidX
Make sure to update your packages! :)
Error message: Important part
[+1099 ms] > Task :package_info:verifyReleaseResources FAILED
[ +10 ms] FAILURE: Build failed with an exception.
[ +10 ms] * What went wrong:
[ +29 ms] Execution failed for task ':package_info:verifyReleaseResources'.
[ +3 ms] java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
[ +7 ms] ...\build\package_info\intermediates\res\merged\release\values\values.xml:171:error: resource android:attr/fontVariationSettings not found.
[ +2 ms] ...\build\package_info\intermediates\res\merged\release\values\values.xml:172:error: resource android:attr/ttcIndex not found.
[ +1 ms] error: failed linking references.
Error message: Distraction
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'barcode_scan'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
"fontVariationSettings not found". is an AndroidX error, which requires you to use compileSdkVersion 28, but I already had that, so I suspect something was implemented between my two Flutter versions to be more restrictive.
So I had to go hunting and updated packages and found that.
"package_info: ^0.3.2" needed to be "package_info: ^0.4.0" to make it work.
To make it "more" future proof write it like this:
package_info: '>=0.4.0 <2.0.0'
After updating packages my code base compiles for release again.
Hope it helps.
I removed all the unused plugins in the pubspec.yaml and in the External Libraries to solve the problem.
My case was really different. I had set android:text=" ??? " property of my TetxtView in my layout file, when I changed it to android:text=" ? " it worked. I have no idea why this works, maybe it helps someone. It took me hours to find the issue.
I had the same issue and I installed this cordova plugin and problem solved.
cordova plugin add cordova-android-support-gradle-release --save

All com.android.support libraries must use the exact same version specification : 27.0.2

After updating targetSdkVersion to 27 I got this error message.
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 25.2.0. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:support-media-compat:25.2.0
I understand that I should update com.android.support:support-media-compat but I dont know how because I am not using it in build.gradle , I tried to update SDK tools but the problem is still remaining . bellow is build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.ex"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.android.gms:play-services-ads:11.6.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.bloder:magic:1.1'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
}
I have checked manually the libraries in project -> .myidea-> libraries then I found that I have two libraries using the old version :
com_android_support_support_media_compat_25_2_0
com_android_support_support_v4_25_2_0
then just by adding this line in builde.gradle
implementation 'com.android.support:support-v4:27.0.2'
The error is gone now.
I encountered the exact same problem. You are not using in your build.graddle but some library that you included in your build.graddle is using. Therefore, you need to override them, which are pointed in warning, in your build.graddle
I have gotten this error before. Try clicking build on Android Studio Toolbar.
Clean Build
After Step 2, Click Rebuild Project.
Update
If not, try explicitly adding implementation com.android.support:support-media-compat:27.0.2 to the build
What you are dealing with appears to be transitive dependencies. In other words just as you use gradle so you don't have to re-invent the wheel the maker of the dependency you are using also uses dependencies. It appears the problem is with this dependency 'com.github.bloder:magic:1.1' because it depends on 'com.android.support:appcompat-v7:23.1.1'. I found this out by visiting the repository pom description for blogger magic. In android studio I could also have also clicked on the gradle tab on the right and found one of the dependency task and found the conflict this way. Now that we know the problem excluding a transitive dependency may help checking to see if all dependencies are up to date may help or not using blogger magic at all may help. This problem is difficult, I know. Just hope this helps.
I encountered similar problem when updated the gradle. I implicitly declared the error written support library. I had to perform this implicitly for 3 more support libraries. This error does not solve by implicitily declaring a support library. If u want to solve the problem immediately, then replace all 27.0.2 to 25.2.0 in com.android.support.* libraries.
As you already seen the all answers and comments above but this answer is to clear something which a new developer might not get easily.
./gradlew -q dependencies app:dependencies --configuration compile
The above line will save your life with no doubt but how to get the exact point from the result of above line.
When you get the all dependency chart or list from the above command then you have to search the conflicting version number which you are getting in your code. please see the below image.
in the above image you can see that 23.4.0 is creating the problem but this we not able to find in our gradle file. So now this version number(23.4.0) will save us. When we have this number then we will find this number in the result of above command result and directly import that dependency directly in our gradle file. Please see the below image to get the clear view.
you can clearly see that com.android.support:cardview-v7:23.4.0 and com.android.support:customtabs:23.4.0 are using the version which is creating the problem. Now just simply copy those line from dependency
list and explicitly use in our gradle file but with the updated version link
implementation "com.android.support:cardview-v7:26.1.0"
implementation "com.android.support:customtabs:26.1.0"
Please refer this to see the original answer
https://stackoverflow.com/a/49169228/4156595

Android studio build failing because of dependencies

I get this message Error in Android studio and I don't know why I added card view and recycler and this came threw
if you know something please help me?
The error probably because you have mix version of support library.
Use the same version of all support library. Don't use alpha version, something like this:
dependencies {
...
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:design:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.android.support:cardview-v7:25.3.0'
}
And make sure your compileSdkVersion, buildToolsVersion, and targetSdkVersion is the same version which is 25.

android - java.lang.NoClassDefFoundError Samsung s5 - 4.4.2 [duplicate]

So far I got this error only for one user, who uses a rooted phone (SM-G900R7 Android 4.4.2). The error is like this:
Fatal Exception: java.lang.NoClassDefFoundError: android/graphics/drawable/Icon
at java.lang.Class.getDeclaredMethods(Class.java)
at java.lang.Class.getDeclaredMethods(Class.java:656)
at android.view.ViewDebug.getExportedPropertyMethods(ViewDebug.java:960)
at android.view.ViewDebug.exportMethods(ViewDebug.java:1047)
at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:997)
at android.view.ViewDebug.dumpViewProperties(ViewDebug.java:983)
at android.view.ViewDebug.dumpView(ViewDebug.java:900)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:870)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dumpViewHierarchy(ViewDebug.java:867)
at android.view.ViewDebug.dump(ViewDebug.java:793)
at android.view.ViewDebug.dispatchCommand(ViewDebug.java:416)
at android.view.ViewRootImpl$W.executeCommand(ViewRootImpl.java:6258)
at android.view.IWindow$Stub.onTransact(IWindow.java:65)
at android.os.Binder.execTransact(Binder.java:404)
at dalvik.system.NativeStart.run(NativeStart.java)
I never use android.graphics.drawable.Icon in my code, all usages are from android.support.v4.graphics.drawable.IconCompat and I also never use that class in my code...
Btw my support library is version 26.0.0, my minSdkVersion is 15 targetSdkVersion is 26.
Thanks
Update
The issue is fixed in support library 27.0.0. If you update don't forget to change compileSdkVersion 27 as well.
What is happening?
Samsung devices with Android 4.4 crash like this when classes extending View define methods which return or take parameters of types that are not on classpath.
Starting with support library version 25.4.0 AppCompatImageView and AppCompatImageButton incorrectly overrides setImageIcon(Icon) method. Since Icon class was introduced in API 23 the app crashes on Samsung devices with API 19.
Similar thing happens when you try to override View.onApplyWindowInsets(WindowInsets).
Workaround for support library 26.1.0
Until this gets fixed in an official manner, If you're stuck with an older version of the support library, I made a modified version of appcompat-v7 where all traces of setImageIcon methods are removed. This means it won't crash on a Samsung with Android 4.4.
Put this at the bottom of your app's build.gradle:
repositories {
maven { url "https://dl.bintray.com/consp1racy/maven" }
}
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name == 'appcompat-v7') {
details.useTarget 'net.xpece.android:support-appcompat-v7-fixed:26.1.0-1'
}
}
}
This code will replace appcompat-v7 dependency with the described modified artifact.
Currently the only supported version of the fix is 26.1.0.
Warning: Understand the code before copy-pasting, and always exercise caution when getting code from unknown sources!
This issue was resolved in support library 27.0.0:
Android Gradle Plugin 3.x:
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support:support-v4:27.0.0'
Android Gradle Plugin 2.x:
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
Note that you will also need to compile against SDK level 27.
This crash related to 25.4.0 version of support library.
Use 25.3.1 version.
Replace
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
With:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
There are 2 options :
Have you changed the support library version ? this is quite classic library issue when the resources sometimes aren't 'saved' with the same name, or at all. Its not you, its google. Try to use support lib 25, and see if this error still occurs.
Try to clean the project and rebuild. Maybe you're kept with some old library versions in your build folder, and when you build your project it takes old values from it.

Categories

Resources