1

When I'm creating an APK I get such an error:

Caused by: java.lang.RuntimeException: java.io.IOException: Can't write [C:\Users\Smokie\Desktop\datemeet\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Smokie\Desktop\datemeet\app\build\intermediates\transforms\desugar\debug\241.jar(;;;;;;**.class)] (Duplicate zip entry [241.jar:android/support/design/widget/CoordinatorLayout$Behavior.class])) at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

my build.gradle file :

apply plugin: 'com.android.application'
apply plugin: 'com.jakewharton.butterknife'
buildscript {
    repositories {
        maven { url "https://github.com/omadahealth/omada-nexus/raw/master/release" }
        maven { url "https://jitpack.io" }
    }

    dependencies {


    }
}

android {
    signingConfigs {
        config {

        }
    }
    lintOptions {
        abortOnError false
    }

    dataBinding {
        enabled = true
    }

    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.oxyn.datemeet"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 5
        versionName "1.0"
        testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            ext.enableCrashlytics = true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            ext.enableCrashlytics = true
            proguardFiles 'proguard-rules.txt'
        }
    }

    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/**'
        exclude 'META-INF/**'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    mavenCentral()
    jcenter()

}

android {
    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // Navigation Drawer Library
    compile('com.mikepenz:materialdrawer:5.3.0@aar') {
        transitive = true
    }

    //Google, Inc (Play services) Libraries

    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation 'com.google.android.gms:play-services-auth:11.8.0'
    implementation 'com.google.firebase:firebase-core:11.8.0'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-crash:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-config:11.8.0'
    implementation 'com.google.firebase:firebase-appindexing:11.8.0'
    implementation 'com.google.android.gms:play-services-appinvite:11.8.0'

    //Google, Inc (Firebase) Libraries

    implementation 'com.firebase:firebase-jobdispatcher:0.6.0'
    implementation 'com.firebaseui:firebase-ui-database:2.3.0'
    implementation 'com.firebase:geofire-android:2.1.2'

    // Google, Inc (Support) Libraries

    implementation 'com.android.support:support-v13:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'
    implementation 'com.android.support:support-v4:27.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:palette-v7:27.0.2'
    implementation 'com.android.support:support-vector-drawable:27.0.2'

    // Facebook, Inc SDKs

    implementation 'com.facebook.android:facebook-android-sdk:4.29.0'

    // Libraries for images

    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation 'com.lorentzos.swipecards:library:1.0.9'
    implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
    implementation 'com.vanniktech:emoji-twitter:0.5.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
    implementation 'com.github.yalantis:ucrop:2.2.1'
    implementation 'com.github.jkwiecien:EasyImage:1.3.1'
    implementation 'jp.wasabeef:picasso-transformations:2.1.2'
    implementation 'com.squareup.picasso:picasso:2.5.2'

    // Location Helper Library

    implementation 'com.squareup.retrofit2:retrofit:2.2.0'
    implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta1'

    // Time library

    implementation 'joda-time:joda-time:2.9.9'
    implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'


    implementation 'org.greenrobot:eventbus:3.0.0'
    implementation 'com.jakewharton:butterknife:8.8.1'
    implementation 'com.flipboard:bottomsheet-core:1.5.3'
    implementation 'com.flipboard:bottomsheet-commons:1.5.3'
    implementation 'com.greysonparrelli.permiso:permiso:0.3.0'
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.5.2'
    implementation 'com.airbnb.android:lottie:2.2.5'

    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

}
apply plugin: 'com.google.gms.google-services'

I'm using Android Studio 3.1

when I updated the libraries: import static com.google.android.gms.internal.zzahn.runOnUiThread; the code is failing.

    implementation 'com.android.support:support-v13:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:palette-v7:27.1.0'
    implementation 'com.android.support:support-vector-drawable:27.1.0'

error: cannot find symbol static runOnUiThread

I Changed Android Studio Version 2.3.3. Now Perfectly works.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Özgür Can Karagöz
  • 1,039
  • 1
  • 13
  • 32
  • Downgrading the IDE isn't really a solution here. You will have to upgrade eventually – OneCricketeer Apr 05 '18 at 22:36
  • @cricket_007 frankly I'm not too happy with me. I am experiencing a lot more problems when I update it. – Özgür Can Karagöz Apr 05 '18 at 22:46
  • Your Firebase UI dependencies are just the wrong version. I don't see how downgrading the IDE but keeping the same Gradle build process affects anything. In other words, building the project from the CLI should produce the same error... Anyway, match your versions https://github.com/firebase/FirebaseUI-Android/blob/master/README.md#compatibility-with-firebase--google-play-services-libraries Also, I would suggest not using both Picasso and Glide in the same project, or even Joda-time when ThreeTen exists – OneCricketeer Apr 06 '18 at 03:26
  • 1
    I had the same issue before. You have to force the libraries to use a certain version. Check the answer here: https://stackoverflow.com/a/49509295/6947235 – Anky An Apr 06 '18 at 10:24

2 Answers2

1

You might have the jar in your libs folder. Please check, if it is there, then remove it ,and clean and build it again.

casillas
  • 16,351
  • 19
  • 115
  • 215
0

I have same Error in recent Days i solved to changing the support library version

    implementation 'com.android.support:support-v13:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:palette-v7:27.1.0'
    implementation 'com.android.support:support-vector-drawable:27.1.0'
Nikunj Paradva
  • 15,332
  • 5
  • 54
  • 65