Compatibility error when importing picasso library to android studio - java

this is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.villegas.juliana.dreavel_app"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
when i copy the picasso dependency it throws this error in this line
compile 'com.android.support:appcompat-v7:23.4.0'
error : All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 24.0.0, 23.4.0. Examples include com.android.support:support-v4:24.0.0 and com.android.support:animated-vector-drawable:23.4.0 more... (Ctrl+F1)

Related

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException

I'm new at android. I'm trying to add Google sign in feature in my app but when i add com.google.android.gms:play-services-auth:17.0.0 in my build.gradle file,
i'm getting following this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: androidx/versionedparcelable/CustomVersionedParcelable.class
Kindly suggest solution, i spend whole day but cant get solution.
Build.gradle code is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "29.0.1"
defaultConfig {
multiDexEnabled true
applicationId "com.example.mawai.smartlearn"
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 {
compile 'com.android.support:multidex:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:appcompat-v7:28.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-auth:17.0.0'
}
In version 17.0.0 and above, you need to use AndroidX, so you have 2 options:
1) Downgrade com.google.android.gms:play-services-auth to older version
2) Add/Migrate AndroidX to your app (Recommended)
Check this link for migration

I am getting the error' compile 'com.android.support:design:23.0.1' compile 'com.android.support:appcompat-v7:23.0.1'

Below is my build.gradle
its giving me the below error if i generate a signed apk
"Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/integration/android/IntentIntegrator;"
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.funanindou.grocerylist"
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 {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//compile 'com.android.zxing:core:3.2.0'
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
testCompile 'junit:junit:4.12'
}
kindly assist on how i can fix this error
Seems like you are including the com.journeyapps:zxing-android-embedded library twice, could be thet you have also saved a jar of it in your lib folder?

Andrioid Studio - Error converting bytecode to dex, Cause: Dex cannot parse version 52 byte code

Below is the content of my build.gradle for an android studio project :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.nariman.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'net.time4j:time4j-calendar:4.20'
compile 'net.time4j:time4j-olson:4.0'
testCompile 'junit:junit:4.12'
}
bur I get the below ERROR :
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
As you can see , I have already tried adding targetCompatibility and sourceCompatibility , but the issue persist.
I searched and seems there are similar issues reported, but seems now yet find a solution for this.
I needed to use the latest version of the time4j , so going back to Java 7 versions of the time4j lib was not an option.
I found out there is a sister project for time4j which is for Andriod, its called time4a or time4j-android . So I changed the build.gradle as follow and it solved the issue :
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.nariman.myapplication"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile group: 'net.time4j', name: 'time4j-android', version: '3.24-2016i'
testCompile 'junit:junit:4.12'
}
This line solved my issue :
compile group: 'net.time4j', name: 'time4j-android', version: '3.24-2016i'

Android Studio, unknown error while setting up AdMob + cannot resolve symbol 'R'

In my build.grade, when I put in the code:
apply plugin: 'com.google.gms.google-services'
An error comes up that says:
Error:(35, 0) Plugin with id 'com.google.gms.google-services' not found.
Why is this?? Its messing up my entire project. Here is my gradle code:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.apps.stephenshettler.laughsoundboard"
minSdkVersion 16
targetSdkVersion 24
versionCode 4
versionName "2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.google.firebase:firebase-ads:9.6.1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-appindexing:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
Help is greatly appreciated! Thanks!
Have you added this in the project's build.gradle
classpath 'com.google.gms:google-services:1.3.0'
When it comes to cannot resolve the symbol 'R', Simply clean or Rebuild the project or Invalidate/Restart like Firdoesh mentioned.
For this you can try putting compile 'com.google.android.gms:play-services-analytics:9.2.1' this in gradle, it does the same job.
and for R go to File > Invalidate/Restart

Could not find support-v4.aar(com.android.support:support-v4:24.1.1)

The project is one of Google samples on Github, Androidtv-Leanback. I cloned it and opened with Android studio, but build fails.
Error:
Could not find support-v4.aar(com.android.support:support-v4:24.1.1)
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '24'
defaultConfig {
applicationId "com.example.android.tvleanback"
minSdkVersion 21
targetSdkVersion 24
versionCode 2
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:leanback-v17:24.1.1'
compile 'com.android.support:recommendation:24.1.1'
compile 'com.android.support:preference-leanback-v17:24.1.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.1'
androidTestCompile 'com.android.support:support-annotations:24.1.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile 'com.google.android.exoplayer:exoplayer:r1.5.8'
// compile files('src/libs/android-support-v4.jar')
}
add this dependency in your build.gradle file
dependencies {
...
compile "com.android.support:support-v4:24.2.1"
}
and make sure you have downloaded the android support repository using sdk manager.

Categories

Resources