I am converting a project from Eclipse to Android Studio. It wasn't easy. I tried to put the AdMob banner and I got an error like this.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/ads/identifier/AdvertisingIdClient$zza.class
There's only 1 AdvertisingIdClient$zza.class file in the project.
Why am I getting this error?
I have spent many hours on this, but no clues.
Can anyone help me, please?
Thanks for all replies. Here's my gradle files.
app-gradle >>>>
apply plugin: 'com.android.application'
android {
compileSdkVersion 13
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "sw.ko.aaaaa.bbbbb"
minSdkVersion 9
targetSdkVersion 9
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
dependencies {
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/commons-email-1.2.jar')
compile files('libs/commons-net-2.0.jar')
compile files('libs/google-play-services.jar')
compile files('libs/mail.jar')
compile files('libs/twitter4j-core-android-2.2.5.jar')
}
apply plugin: 'com.google.gms.google-services'
Another gradle file is...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
External Libraries...
Android API 13 Platform
1.8
firebase-analytics-9.0.0
firebase-analytics-impl-9.0.0
firebase-common-9.0.0
firebase-core-9.0.0
firebase-iid-9.0.0
multidex-1.0.1
multidex-instrumentation-1.0.1
play-services-base-9.0.0
play-services-basement-9.0.0
play-services-tasks-9.0.0
support-v4-23.0.0
Remove all references to Google Play Services (JAR files and other Gradle lines)
Add this one for Admob
dependencies {
...
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
Add more dependencies for other Google or Firebase services.
I'd prefer to do it this way to keep all versions the same.
ext {
// Variables to keep libraries consistent
googlePlayServicesVersion = '10.0.1'
}
dependencies {
...
compile "com.google.android.gms:play-services-ads:${googlePlayServicesVersion}"
}
Related
I am trying to build a signed Apk of my project and i get the following error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/internal/zzv$zza$zza.class
When I choose the debug build type I got no errors and everything works fine. I searched for a while to fix this but i found nothing useful.
My build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.danielsous.demos"
minSdkVersion 14
targetSdkVersion 24
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile files('libs/scanditsdk-android-4.7.5.jar')
compile 'com.android.support:support-v4:24.2.1'
compile 'com.github.attenzione:android-ColorPickerPreference:e3aa301016'
compile 'com.google.firebase:firebase-messaging:9.4.0'
compile 'com.google.code.gson:gson:2.7'
}
The other build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
I had 1 library and a second library made from an aar file which contained multiple resource with the same names ( pngs files with same names, strings with the same ids, layouts with the same files ). Removing the aar library fixed my issues
It seems that you have more than one libraries added for printHelper.
Every time that you face a duplicate entry error run ./gradlew app:dependencies and make sure that there is no duplicated versions of a same module.
I want to add to my app some ads using AdMob, the site says I need to add Google Services to the dependencies to use this functionality. So with Android Studio I went to File->Project Structure->app->Dependencies, I clicked on the "+" button e searched for "play-services". What I found was "com.google.android.gms:play-services:9.4.0" so I added it to the dependencies. During the gradle sync however Android Studio sends some errors and stops the gradle sync.
This is the log I get form the sync: http://pastebin.com/ZpN4RUcm
Here some data that might be useful:
Compile SDK Version: API 17
Build Tools Version: 23.0.1
Android
Studio 2.1.2
This is my main gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
And this is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.serpenssolida.glowdodger"
minSdkVersion 10
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:support-v4:17.0.0'
compile files('libs/processing-core.jar')
compile project(':facebook')
compile 'com.google.android.gms:play-services:9.4.0'
}
How can I get rid of all the errors?
Change your app gradle file as below and try again:
apply plugin: 'com.android.application'
android {
compileSdkVersion '24'
buildToolsVersion '24.0.2'
...
}
I want to use MusicBobber library in my project, but this error showed up
Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
I have com.android.support:appcompat-v7:23.1.1
and this is complete gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tabaneshahr.playaudiotest"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.cleveroad:audiowidget:0.9.2'
}
I'd searched stackoverflow but noting useful. what should I do? does minSDK must change? shall I download anything?
First, replace your appcompat compile line with the latest one like this:
compile 'com.android.support:appcompat-v7:24.2.0'
Update to the targetSdkVersion 24 as well.
and remove the compile line for the library:
compile 'com.cleveroad:audiowidget:0.9.2'
Second, clean/build and run the project, you should not get any errors. If this happened, then your problem is not with the appcompact at all, but it is with the library.
Thrid, try to add the library compile line and again and let the gradle sync. If you still getting a problem, then I recommend to save your self the hassle and integerate the library in your code manually by doing the following this link steps
Hope it helps!
Please update your build tool version :
buildToolsVersion "23.0.2"
to 25 or you can use
compile 'com.android.support:appcompat-v7:23.0.0'
Clean and rebuild your android project.
> create a new project and you will see exact version .
for example for me in project file was :
compile 'com.android.support:appcompat-v7:24.2.0'
but after created new project i saw it is like this :
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
so changed and sync and fixed .
I ran into this error while trying to run SQLite Android Bindings. It still uses a very old gradle configuration (included below).
TLDR
com.android.support:appcompat-v7:23.4.0 is very old and only available on https://maven.google.com (google() in build.gradle) as of this writing. Make sure your root build.gradle includes the google() repository in its allprojects.repositories section:
allprojects {
repositories {
jcenter()
google()
}
}
SQLite's woefully out of date gradle configuration:
$ROOT/build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
// this was the problem. google() was missing!
}
}
$ROOT/sqlitetest/build.gradle:
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}
I researched similar questions but none of the answers solved my problem. When I try to build the starter code for a coding assignment I get the following error:
Error: Cause: Peer not authenticated
My gradle files are the following:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.sam_chordas.stockhawk"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
compile 'net.simonvt.schematic:schematic:0.6.3'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile 'com.android.support:design:23.1.1'
compile('com.github.afollestad.material-dialogs:core:0.8.5.7#aar') {
transitive = true
}
}
I didn't manage any of those files as I don't have gradle experience yet.
Could you help me to figure out what went wrong?
Thank you very much.
P.S.:
The log files give me this error:
2016-03-23 13:01:29,664 [3912009] INFO - .BaseProjectImportErrorHandler - Failed to import Gradle project at '/home/madelenko/Desktop/Stock-Hawk master'
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.4-all.zip'.
Followed by a gigantic traceback.
I've followed following topic with no result. Decided to find|grep all support-v4 contents in project folder and remove them. Every time I make and run project it respons with:
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
My build.gradle from module is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.android"
minSdkVersion 14
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.+'
compile 'com.android.support:appcompat-v7:+'
}
build.gradle from project root:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
allprojects {
repositories {
jcenter()
}
}
I know it is similar topic but suggested sollution does not fit this case.
I would appreciate any explanation of this all dependencies structure which might have impact in that problem.
When we find|grep for "support-v4" inside this project folder it looks like this:
...\.gradle\1.12\taskArtifacts\fileSnapshots.bin
...\.gradle\1.12\taskArtifacts\taskArtifacts.bin
...\.idea\workspace.xml
...\.idea\libraries\support_v4_21_0_0_rc1.xml
...\app\app.iml
...\app\build.gradle
...\app\build\intermediates\incremental\mergeResources\debug\merger.xml
...\build\intermediates\model_data.bin
Regards
Replace:
compile 'com.android.support:appcompat-v7:+'
with:
compile 'com.android.support:appcompat-v7:19.1.0'
In general, do not use + wildcards at the top version level. If you wanted to use 19.1.+, or even 19.+, I wouldn't argue (though others would).