App is crashing but there is no error in the code - java

I am getting java.lang.NoSuchMethodError in the error log and after that app is crashed. I am not getting any error in my java code. I am not sure which library is causing this issue. Your help is highly appreciated.
I have updated few libraries to 28 and to 27 but still getting the same error.
Error
java.lang.NoSuchMethodError: No static method getScreenWidthDp(Landroid/content/res/Resources;)I in class Landroid/support/v4/content/res/ConfigurationHelper; or its super classes (declaration of 'android.support.v4.content.res.ConfigurationHelper' appears in /data/app/com
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.test.test"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
implementation 'com.github.d-max:spots-dialog:1.1#aar'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.facebook.android:account-kit-sdk:4.+'
}
If I update the appcompat to 28 then I am getting below error.
implementation 'com.android.support:appcompat-v7:28.0.0'
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.design.widget.CoordinatorLayout$1

Without the full stacktrace it is impossible to tell where the error originates. The only thing that looks suspicious in your build file is that you don't have a common android support version. You use libraries of both the 27.0.0 and 28.0.0 versions.

After adding implementation 'com.android.support:design:28.0.0' then this issue got resolved. Thanks everyone for your comments.

Related

How to update com.google android.gms:play-services-auth:16.0.1?

I am trying to run a code in android-studio but I get following warning "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-v4:26.1. " How can I fix this?
I know that the problem is in this line:
implementation 'com.google.android.gms:play-services-auth:16.0.1'
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.irma"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
**implementation 'com.android.support:support-media-
compat:28.0.0'**
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-
layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
**implementation 'com.google.android.gms:play-services-auth:16.0.1'**
}
So I have conflict here: implementation 'com.android.support:support-media-compat:28.0.0' and here: implementation 'com.google.android.gms:play-services-auth:16.0.1'
But play services-auth is already updated, but the program still says its on version 26.1.0.
You need to update the Google Sign-In lib to the latest version.
In my case, I need to update my v7 AppCompat to v28. After doing so, the issue you stated surfaced. Updating com.google.android.gms:play-services-auth:16.0.1 to the latest version would result to Manifest conflicts because the latest version uses Androidx. You either migrate your project to Androidx to support play-services-auth's latest version or make exclusion in the dependencies. I didn't want to migrate to Androidx yet, so the latter works for me. I added the following to the gradle file:
implementation ('com.google.android.gms:play-services-auth:16.0.1'){
exclude group: 'com.android.support', module:'support-v4'
}
Set Up - Google Play Services, as follow you can see the lastest versions. Google Play Services

How to fix This "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)"

I am creating an app that uses firebase authentication for login and registration but I keep getting sudden crashes as soon as I run the application. I'm getting a warning in my Gradle.build file at the app level. The warning says
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0
I've tried changing com.android.support:appcompat-v7:28.0.0 to v7:26.0.1 and 27.1.0 but none of them solved the problem.
My build.gradle file is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.project.tck.rescueme_responder"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
I expect a login that authenticates using FireBase when I run the application but then the application crashes each time I run it.
There is a similar question here
I guess the problem is in the transitive dependencies of the direct dependencies you use since I don't see them explicitly referenced in your build.gradle file. Some of them use one version (28.0.0) while some another (26.1.10).
The above referenced answer provides some workarounds. Furthermore, depending on the Gradle version you use (if it is >=4.6), you may be able to add constraints for those transitive dependencies in your build.gradle file to be sure they use the version you want.

Android Studio Failed to resolve: com.android.support:appcompat-v7.28.0.0

I am getting this error, Failed to resolve: com.android.support:appcompat-v7.28.0.0 I have been looking on here and tried changing it to other variations of that line but so far no luck, why do I keep getting this error?
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7.28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:11.6.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
The issue is with the appcompat-v7 dependency that you have added to the build.gradle.
Change implementation 'com.android.support:appcompat-v7.28.0.0' to implementation 'com.android.support:appcompat-v7:28.0.0'
Notice the : between appcompat-v7 and 28.0.0 that separates the artifact name and the version.
If we don't consider the typo in :
implementation 'com.android.support:appcompat-v7.28.0.0'
Change it to:
implementation 'com.android.support:appcompat-v7:28.0.0'
Then, you probably should use the latest version for the Firebase dependencies to avoid those Please fix the version errors:
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-database:16.0.3'
Then rebuild the project. Also, remember to use latest gradle to avoid couldn't found such dependency or etc.
Inside build.gradle of the project (inside your project root directory):
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
// replace it with the 3.2.0 version
...
classpath 'com.google.gms:google-services:4.1.0' // update this too
}

Got error while testing App - Firebase Test Lab

I just cannot understand what error is this. I got it when I tried to test my app on a device from the Firebase Test Lab. When I test the app on my phone and on the android emulator in Android Studio, everything works fine, but here, at the first activity created, I get this error that I don't know what means. If you know the problem, or how to solve it, please help me out. Thanks
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "edurbrito.SuperLigaUsers"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'org.apache.commons:commons-lang3:3.7'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.support:design:26.1.0'
implementation 'com.shawnlin:number-picker:2.4.6'
implementation files('libs/activation.jar')
implementation files('libs/additionnal.jar')
implementation files('libs/mail.jar')}
apply plugin: 'com.google.gms.google-services'
Can you please join the #test-lab channel at https://firebase-community.slack.com and then post a sample matrix-id of a test with this failure? A new Firebase Test Lab bug was filed a couple days ago that might be the same as this, but we can't tell without inspecting your test matrix.

Firebase Firestore library causes : java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I am tryng to add Firebase Firestore db to my android application but i get this error:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "nfciue.nfcsmartanimalpassport"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven {
credentials {
username "sdkuser"
password "taplinx"
}
url "http://maven.taplinx.nxp.com/nexus/content/repositories/taplinx/"
}
}
}
dependencies {
//noinspection GradleCompatible
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile('taplinx-android:nxpnfcandroidlib:1.3#aar') {
transitive = true
}
apply plugin: 'com.google.gms.google-services'
}
also "compile 'com.google.firebase:firebase-firestore:11.8.0'" causes warning that says:
All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 10.0.1. Examples include com.google.android.gms:play-services-basement:11.8.0 and com.google.android.gms:play-services-analytics:10.0.1 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)
As a beginner, these errors and warnings are complicated for me. Any help ?
Add this to your app level build gradle:
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
This will clear alway the "All gms/firebase libraries must use the exact same version specification".
As for the dex problem I've encountered the problem many times before and it was always fixed with using the latest version of the compileSdkVersion and of the libraries I was using.

Categories