Java and Kotlin combined build error (Duplicate Zip Entry) - java

I have added Kotlin library to my existing project. After that I'm getting the build error. I commented all the recently added libraries and checked the main problem is after adding kotlin library
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/home/imedrix-server/StudioProjects/kardioscreen-operatorapp/app/build/intermediates/transforms/desugar/debug/76.jar(;;;;;;**.class)] (Duplicate zip entry [76.jar:org/intellij/lang/annotations/Flow.class]))
Project gradle
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath ('com.google.firebase:firebase-plugins:1.0.5') {
exclude group: 'com.google.guava', module: 'guava-jdk5'
}
}
}
allprojects {
repositories {
google()
jcenter()
maven {url "https://maven.google.com"}
}
}
And the app gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-crash'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'com.example.android'
minSdkVersion 20
targetSdkVersion 27
versionCode 17
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
buildConfigField("String", "BASE_URL", "\"url\"")
buildConfigField("String", "API_KEY", "\"key\"")
}
}
productFlavors {
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '.readme'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':controllers')
compile files('libs/achartengine-1.2.0.jar')
compile files('libs/dfuLibrary.jar')
compile 'com.android.support:appcompat-v7:27.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compile 'com.android.support:design:27.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.polidea.rxandroidble:rxandroidble:1.0.2'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
compile 'com.android.support:support-v4:27.0.2'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.jakewharton:butterknife:8.8.1'
testCompile 'junit:junit:4.12'
/*compile 'org.hashids:hashids:1.0.3'
compile 'com.google.dagger:dagger:2.11'
compile 'javax.inject:javax.inject:1'
kapt 'com.google.dagger:dagger-compiler:2.11'
compile 'io.reactivex.rxjava2:rxjava:2.1.3'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.amitshekhar.android:rx2-android-networking:1.0.0'
compile 'com.android.support:multidex:1.0.2'*/
}
apply plugin: 'com.google.gms.google-services'
If I remove the below line from the app gradle everything works fine. But if I add the kotlin library I'm getting the error.
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
How can I use the kotlin and Java together.

Atlast I found the answer, it was due to duplicate entry to annotation which can be solved by using the below lines in the gradle.
configurations {
compile.exclude group : 'org.jetbrains' , module : 'annotations'
}

Related

Error:(30, 18) Failed to resolve: com.android.support:design-v7:25.3.1

I have already add the "maven{url "https://maven.google.com"}" but it doesn't work
This is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my other build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.quizapp.conte.quizapp"
minSdkVersion 21
targetSdkVersion 25
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(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.rengwuxian.materialedittext:library:2.1.4'
compile 'com.android.support:cardview-v7:25.3.1'
debugCompile 'com.android.support:design-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
Any ideas on what I'm doing wrong?
I tried everything and I do not know what to do.
I started the project recently so i didn't modify other files exept the build.gradle.
Thank you all.
Error:(30, 18) Failed to resolve: com.android.support:design-v7:25.3.1
It happens because this dependency doesn't exist.
Use
debugCompile 'com.android.support:design:25.3.1'
instead of
debugCompile 'com.android.support:design-v7:25.3.1'
In new Gradle version(4.1+), you must use google repository like below
allprojects {
repositories {
google()
}
}
If you're using a version of Gradle lower than 4.1, you must instead use
allprojects {
repositories {
maven {
url 'https://maven.google.com'
// An alternative URL is 'https://dl.google.com/dl/android/maven2/'
}
}

Google GTM dependencies error

i use the GTM and have a question,please help me
app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.york.yorkbbs"
minSdkVersion 16
targetSdkVersion 25
versionCode 531
versionName "5.31"
multiDexEnabled true
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
preDexLibraries = true
javaMaxHeapSize "4g"
}
lintOptions{
checkReleaseBuilds false
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
compile project(':library_googlemap')
compile project(':library_jcvideoplayer')
compile 'com.android.support:recyclerview-v7:25.3.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-tagmanager:10.2.1'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.stripe:stripe-android:3.1.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.15.3'//exclude group: 'com.squareup.okhttp3', module:'okhttp'
compile 'com.facebook.fresco:fresco:0.14.1'
compile 'com.facebook.fresco:animated-gif:0.14.1'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.2.1'
compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:1.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.4.1'
compile project(':Qupaisdk-release')
compile 'com.google.code.findbugs:jsr305:3.0.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.4'
compile 'com.google.dagger:dagger-compiler:2.0.1'
compile 'com.google.dagger:dagger:2.0.1'
compile 'jp.wasabeef:blurry:2.1.1'
}
project build.gradle
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
allprojects {
repositories {
jcenter()
}
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 9.0.0.
thanks~
You should rectify your build.gradle
No Need
compile project(':library_googlemap') // Remove this line
Finally
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.android.gms:play-services-tagmanager:10.2.1'

Duplicate files copied in APK AUTHORS

I have this problem when i will to compile my project:
And when i will build my project to APK i have this error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/objectweb/asm/tree/AbstractInsnNode.class
This is my gradle.
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "come.texi.driver"
minSdkVersion 16
targetSdkVersion 23
versionCode 2
versionName "2.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile 'com.jakewharton:butterknife:7.0.1'
//compile 'com.loopj.android:android-async-http:1.4.9'
compile project(':facebooklibrary')
compile project(':slideMenuLibrary')
compile project(':stripe')
compile('com.twitter.sdk.android:twitter:1.13.0#aar') {
transitive = true
}
//compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile('io.socket:socket.io-client:0.7.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
//compile 'com.paypal.sdk:paypal-android-sdk:2.14.4'
compile('com.paypal.sdk:paypal-android-sdk:2.14.4') {
exclude group: 'org.json', module: 'json'
}
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'cz.msebera.android:httpclient:4.4.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.koushikdutta.ion:ion:2.+'
compile 'com.victor:lib:1.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.tools.build:gradle:2.2.3'
testCompile 'junit:junit:4.12'
}
Help me!!
I had the exact same problem, except I am using Android Gradle Plugin 2.3.3, but that's not the issue. Here is how I solved it, hope this will help you.
Inside android, add the packagingOptions to exclude AUTHORS like this:
android {
packagingOptions {
exclude 'AUTHORS'
}
}
Here is some documentation reference

Gradle duplicate entries : build failed

I am running into this issue almost everytime when I add a new module to my app but this time I am not able to resolve it at all. I am sick and tired of not friendly messages and tools of gradle. Someone please help: If you need dependencies output too let me know - it's big :(
Error:
:app:transformClassesWithJarMergingForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/appengine/tools/appstats/Inter
nalProtos$1.class
Here are 4 gradle files:
Top level gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.google.gms:google-services:1.5.0-beta2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'hugo'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.app.myapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
apply plugin: 'com.google.gms.google-services'
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/nineoldandroids-2.4.0.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v13:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.mikhaellopez:circularimageview:2.1.1'
compile 'com.cocosw:bottomsheet:0.+#aar'
compile 'com.github.bumptech.glide:okhttp-integration:1.3.1'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile project(path: ':backend', configuration: 'android-endpoints')
compile project(path: ':commons')
}
Backend gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18'
}
}
repositories {
jcenter();
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'appengine'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
dependencies {
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18'
compile 'com.google.appengine:appengine-endpoints:1.9.18'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.18'
compile 'javax.servlet:servlet-api:2.5'
compile 'com.ganyo:gcm-server:1.0.2'
compile project(path: ':commons')
}
appengine {
downloadSdk = true
appcfg {
oauth2 = true
}
endpoints {
getClientLibsOnBuild = true
getDiscoveryDocsOnBuild = true
}
}
Commons gradle:
apply plugin: 'java'
dependencies {
compile 'com.googlecode.objectify:objectify:4.0b3'
compile 'com.google.code.gson:gson:2.5'
}
you can try like this
compile 'com.android.support:multidex:1.0.1'
It might help you.
you can try this under
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
might help you
I removed compile project(path: ':commons') and it all worked. But I had to put same POJO in both app and backened. Putting them in common screwed up gradle. May be there is better way to share classes across app and backend.

java.util.zip.ZipException: duplicate entry support v4 PrintHelper$1.class

I am not sure what this error means.
Error:Execution failed for task': eCampus : packageAllDefaultFlavorDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: android/support/v4/print/PrintHelper$1.class
my bulid.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "tw.edu.chu.ecampus"
minSdkVersion 11
targetSdkVersion 21
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
mavenCentral()
}
dependencies {
compile project(':G0.10.ABS')//ActionBarSherlock
compile project(':vitamio')
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
compile 'com.android.support:multidex:1.0.1'
androidTestCompile 'com.android.support:multidex-instrumentation:1.0.1'
}
Error does not show up during gradle sync. Just when I try to run the application
What could be the problem?
I meet the same error, and I solve it, but I just give u that my case;
my bulid.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('com.android.support:appcompat-v7:22.0.0')
compile files('libs/android-async-http-1.4.8.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}
the error for is the com.android.support:appcompat-v7:22.0.0 include the support-v4.jar, so I remove it;
solve build.gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile ('com.android.support:appcompat-v7:22.0.0') {
exclude module: 'support-v4'
}
compile files('libs/android-async-http-1.4.8.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/universal-image-loader-1.9.4-with-sources.jar')
}
so maybe u should check ur dependencies, maybe ur compile files have two files include support-v4

Categories

Resources