Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/annotation/CheckForNull.class
Below is my app level gradle file. I tried removing appcompat, support v4, but it was no help. The app is working fine otherwise, I'm getting the error only when I'm trying to generate a signed apk.
buildsript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.aubergine.resqv1"
minSdkVersion 16
targetSdkVersion 25
versionCode 10109
versionName "1.2.0"
// Enabling multidex support.
multiDexEnabled true
// Flag to tell aapt to keep the attribute ids around
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
//For Mint bug reporter
maven { url "https://mint.splunk.com/gradle/" }
//For bug report and crash report
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://maven.localytics.com/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// libs for Material design
// libs for dependency Injection
// libs for Common font for Application
//libs for calling api using Retrofit
//For calling api using retrofit
//For Mint bug reporter
//For graph
//libs for MaterialDesign EditText
//For Circle Image
//for universal image loader
//For Number Picker in Estimated Time https://github.com/KasualBusiness/MaterialNumberPicker
compile('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:2.0.5#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.5'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'biz.kasual:materialnumberpicker:1.2.0'
compile 'com.google.android.gms:play-services-analytics:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.facebook.stetho:stetho:1.4.2'
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
compile 'com.shawnlin:number-picker:2.4.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.localytics.android:library:4.2.+'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
testCompile 'junit:junit:4.12'
}
Also, there are two CheckForNull class, infact there are duplicate classes in jsr-305. The screenshot:
What would be a wise solution to this problem?
Please do clean for gradle build using command ./gradlew clean.
Related
I try to implement firebase into my app. But there is an interference between firebase and google play service.
Here is my build.gradle for the module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.nefrin.client"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'com.github.tajchert:nammu:1.1.3'
compile 'gun0912.ted:tedpermission:1.0.3'
compile 'com.github.jksiezni.permissive:permissive:0.2'
compile 'com.github.arimorty:floatingsearchview:2.0.3'
//compile 'net.sf.sprockets:sprockets-android:4.0.0'
compile 'com.github.michael-rapp:android-material-dialog:4.0.2'
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.google.firebase:firebase-auth:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
And here is build.gradle for the project:
// 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.2'
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I try to run the app I get eventhough I didn't use cardview in my app:
Error:Execution failed for task ':app:prepareComAndroidSupportCardviewV72330Library'.
> Could not expand ZIP 'C:\Users\Nefrin\.gradle\caches\modules-2\files-2.1\com.android.support\cardview-v7\23.3.0\abdf83a0192c03ff190f941c6c885af18d257a2c\cardview-v7-23.3.0.aar'.
Android Studio is underlining the compile 'com.google.android.gms:play-services:11.0.4' and says:
All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.2.0, 11.0.4. Examples include com.google.android.gms:play-services-basement:11.2.0 and com.google.android.gms:play-services:11.0.4 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 the error says all the google libraries should use the same version.
So you should update the play-services library and use the same version as firebase:
compile 'com.google.android.gms:play-services:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
You need to change this line of code:
compile 'com.google.android.gms:play-services:11.0.4'
with
compile 'com.google.android.gms:play-services:11.2.0'
Hope it helps.
Everything was working fine, but after adding this to my android project error building apk started.Here is the error and dependency
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/crashlytics/android/answers/shim/R.class
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
tried excluding it also but error persists.
Here is my full gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://dl.bintray.com/hani-momanii/maven"}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
resConfigs "en_US", "hi_IN"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.digits.sdk.android:digits:2.0.6#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.7#aar') {
transitive = true;
}
compile('io.fabric.sdk.android:fabric:1.3.10#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:gridlayout-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-annotations:25.3.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
compile 'com.amazonaws:aws-android-sdk-ddb:2.2.+'
compile 'com.amazonaws:aws-android-sdk-lambda:2.2.+'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.firebaseui:firebase-ui-database:1.2.0'
compile 'com.google.firebase:firebase-storage:10.2.1'
compile 'com.google.firebase:firebase-appindexing:10.2.1'
compile 'com.github.clans:fab:1.6.4'
compile 'com.amazonaws:aws-android-sdk-cognito:2.3.9'
compile 'hani.momanii.supernova_emoji_library:supernova-emoji-library:0.0.2'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile('io.branch.sdk.android:library:2.6.0#aar') {
transitive = true;
exclude module: 'answers-shim'
}
}
apply plugin: 'com.google.gms.google-services'
If i add the exclude statement to branch and digits then while entering the app it crashes,if added exclude to crashlytics the error persists.But without adding branch everything works perfect no error during apk build too.
I was struggling with this all day today as well. What ended up fixing it for me was rolling back branch to 2.5.9. There obviously seems to be something wrong with the new 2.6.0 release.
Another note for branch I don't have the transitive aar include so it's just
compile ('io.branch.sdk.android:library:2.5.9') {
exclude module: 'answers-shim';
}
Fixed the the issue when removed transitive = true from the dependency
compile('io.branch.sdk.android:library:2.6.0#aar') {
exclude module: 'answers-shim'
}
For those who want to use the latest version of branch.io, you have to add the following lines in your proguard file.
-dontwarn com.crashlytics.android.answers.shim.**
-dontwarn com.google.firebase.appindexing.**
-dontwarn com.android.installreferrer.api.**
With this change exclude module: answers-shim is not required in the gradle file.
In my project i have implemented play-services-games,first I have tried to add
compile 'com.google.android.gms:play-services:10.0.1'
but i got into some troubles and the solutions that i found was to compile only the needed library
compile 'com.google.android.gms:play-services-games:10.0.1'
and all was great but when I've tried to add play-services-ads things got messy,I have added
compile 'com.google.android.gms:play-services-ads:10.0.1'
Now i get
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzqv.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.apps.fightersam"
minSdkVersion 15
targetSdkVersion 25
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'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile name: 'unity-ads', ext: 'aar'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.google.android.gms:play-services-games:10.0.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile project(':BaseGameUtils')
}
repositories {
flatDir {
dirs 'libs'
}
}
You have to exclude the duplicate use of an internal transitive dependency.
To find out which
gradle -q dependencies
This will give you the dependency tree. Then you can do something like
compile('com.example.m:m:1.0') {
exclude group: 'org.unwanted', module: 'x
}
I was using the latest version of FirebaseUI 2.0.0 which seemed to be incompatible with google-services:3.0.0. Therefore I downgraded FirebaseUI version to 1.2.0 and added the following code to Project level build.gradle:
allprojects {
repositories {
jcenter()
// Add the following
maven {
url 'https://maven.fabric.io/public'
}
}
}
I had a problem like this, but in my case I have two versions of the Google libraries being imported. In your case
delete this from your dependencies:
compile 'com.google.android.gms:play-services-ads:10.0.1'
Because it's imported from:
compile name: 'unity-ads', ext: 'aar'
Or do the opposite delet unity-ads and let compile 'com.google.android.gms:play-services-ads:10.0.1'
goodluck
In my case Downgrading Both 'com.google.android.gms:play-services-games:10.0.1' and 'com.google.android.gms:play-services-ads:10.0.1'
To 'com.google.android.gms:play-services-games:9.0.1' and 'com.google.android.gms:play-services-ads:9.0.1' did the trick !
In my Android app I'm trying to implement ORM for SQLite database for existing db. I've tried to implement activeandroid and DBFlow, but Android studio shows error that it can't recognize method. Here's how it shows when I try to use DBFlow ORM and similarly for activeandroid it doesn't recognize methods in annotations. The red in below screenshot is error. It says it can't recognize method databaseName and also constant PRIMARY_KEY doesn't exist.
Here's project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here's app: build.gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myapplication"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'org.immutables:gson:2.0.6'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup:otto:1.3.8'
compile 'com.airbnb:deeplinkdispatch:1.5.0'
apt 'com.airbnb:deeplinkdispatch-processor:1.5.0'
apt 'com.github.Raizlabs.DBFlow:dbflow-processor:3.0.0-beta1'
compile "com.github.Raizlabs.DBFlow:dbflow-core:3.0.0-beta1"
compile "com.github.Raizlabs.DBFlow:dbflow:3.0.0-beta1"
}
my Gradle suddenly decided not to build my project anymore, and I have no idea. I suspect its because its on dropbox, but it hasnt been a problem for the month Ive worked on it. I have not edited anything in my build files. I updated java JDK to newest, and made sure the project is pointed to it. The gradle look like this;
// 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:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 22
}
dependencies {
}
and
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.nan.spymap"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories { mavenCentral() }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: 'ParseFacebookUtilsV4-*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:design:22.2.0'
}
build.gradle file of project (top-level) must not contain android root tag. Try to remove it.