Dependency conflict in android studio when using firebase - android

I built a normal android app which uses Firebase to store data(name,email and number) and it runs perfectly but i have a dependency conflict error which i am unable to solve. the message which i get "Message Gradle Build" is:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (25.2.0) and test app (25.4.0) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
and my build.gradle file contains:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.arya.anish.myfirebaseexample"
minSdkVersion 19
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'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
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'
}
apply plugin: 'com.google.gms.google-services'
how to overcome this error?

try adding this to your app level .gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
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') {
exclude group: 'com.android.support', module: 'support-annotations'
}
}

finally figured out how to solve the dependency conflict
i added this line in the build.gradle file in the depndencies block:
compile 'com.android.support:support-annotations:27.0.2'
and bingo, no errors now.

Related

cannot use Arr library in project build with androidx

I have migrated my project to androidx. my project depends on some third party libraries, i'm using one arr file in my project. after migration, i'm getting error like below.
Unable to resolve dependency for ':app#debug/compileClasspath': Failed
to transform file 'csjsdk-beta.aar' to match attributes
{artifactType=processed-aar} using transform JetifyTransform Show
Details Affected Modules: csjsdkdemo-app
here is app level gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.demo.csjbot.csjsdkdemo"
minSdkVersion 21
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'
}
}
sourceSets {
main {
// 将 jniLib 指向 libs
jniLibs.srcDir 'libs'
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout: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(name: 'csjsdk-beta', ext: 'aar')
implementation 'io.netty:netty-all:4.1.23.Final'
implementation 'com.google.code.gson:gson:2.8.1'
}
can anyone help me on this?
Try clearing your gradle caches which should be stored here: C:\Users\<username>\.gradle\caches\transforms-1, and then rebuild the project.
Edit:
Change your dependencies in build.gradle to use AndroidX namespace:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation(name: 'csjsdk-beta', ext: 'aar')
implementation 'io.netty:netty-all:4.1.23.Final'
implementation 'com.google.code.gson:gson:2.8.1'
After migrating into Android X, you need to do some steps to clear all the un-used imports.
To clear all those un-used imports :-
Right click on src:- You will get an option "Optimise imports"
Once you are done with this optimisation. Check it out all the changes in github.
If still you are getting same issue.
Close the project. Re-import the project again.

Android project syncing Error

This is my build.gradle(Module:App) code
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mashitha.smartwaterbottle"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url 'https://jitpack.io' }
jcenter()
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:11.4.0'
implementation 'com.google.firebase:firebase-storage:11.4.0'
implementation 'com.google.firebase:firebase-auth:11.4.0'
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:support-annotations:27.1.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation('com.google.apis:google-api-services-calendar:v3-rev328-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'joda-time:joda-time:2.9.4'
implementation 'com.jjoe64:graphview:4.2.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
compile 'me.itangqi.waveloadingview:library:0.3.5'
//Google play services
compile 'com.google.android.gms:play-services:11.4.0'
}
apply plugin: 'com.google.gms.google-services'
I get this Error, when i sync the project.
Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.0.
Please Give an answer for fixed this error.
Thank you
you applied two different versions of google play services
compile 'com.google.android.gms:play-services:11.4.0'
and
implementation 'com.google.android.gms:play-services-auth:15.0.1'
please unify the API version to be latest version 15.0.1
also it is recommended to use latest version of Firebase Cloud Services APIs
you could check it here

error after push and pull from git

i had a android studio project and it was wroks. I had push it to gitlab and after remove it , i had pull it again.
now i get this error when i want to build my gradle:
Error:The module 'app' is an Android project without build variants, and cannot be built.Please fix the module's configuration in the build.gradle file and sync the project again.
it's my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "sample.spart.com"
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'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.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'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.android.support:recyclerview-v7:26.0.0-alpha1'
}
what is the problem and how i can fix it??
Maybe you can try invalidating your cash.
in Android Studio:
File -> Invalidate Caches / Restart
Sharing your project's build.gradle file may help.

Unable to merge dex this error keeps getting everytime

The error is Error
:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. >
java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
I have tried all the solutions given on stackoverflow but none of them worked for me.
This is app level gradle file. I think I am using all the latest dependencies.
app level build.gradle file is uploaded here. help me to solve this problem
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId"com.example.pratikrathi.registerapp"
minSdkVersion 20
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled = true
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:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraintlayout:1.0.2'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-firestore:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.android.support:support-v4:26.1.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'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
apply plugin: 'com.google.gms.google-services'
You are mixing old firebase dependencies with the new firebase dependencies.
You need to remove the following from your root build.gradle dependencies:
classpath 'com.firebase:firebase-client-android:2.3.1'
Then check and remove old firebase depedencies from your module build.gradle. Please read https://firebase.google.com/support/guides/google-android
UPDATE
You also have a duplicated support library.
'com.theartofdev.edmodo:android-image-cropper:2.6.+' library implicitly using support library version 27+, which you can check from its root build.gradle.
You can fix it by exclude support library from image-cropper like this:
implementation ("com.theartofdev.edmodo:android-image-cropper:2.6.+") {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
Or updating all of your support library to version 27.1.0.

Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath':

Im currently using Android Studio 3.0 i just created project on it the gradle offline work is already disabled and it says
Error:Unable to resolve dependency for
':app#debugAndroidTest/compileClasspath': Could not resolve
com.android.support:appcompat-v7:26.0.0-beta1.
Open File<br>Show Details
screen shot
Buid Gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ivan.notification"
minSdkVersion 15
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'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
Remove the -beta1 from your appcompat support library dependency:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}
Then, sync your project.

Categories

Resources