Error: execution completed for task ': app: transformClassesWithMultidexlistForDebug' android studio

I create a game on the assembly I export the project, but I can not start the game on the Android studio My problem is that I can not start the application or create the apk file

someone can help me.

Error

Error: execution completed for task ': app: transformClassesWithMultidexlistForDebug'. java.io.IOException: Unable to write [C: \ Users \ youne \ Desktop \ android2 \ app \ build \ intermediates \ multi-dex \ debug \ componentClasses.jar] (Unable to read [C: \ Users \ youne.gradle \ caches \ transforms-1 \ files-1.1 \ support-core-ui-25.2.0.aar \ 9adfc8649fc899fbc5e371e8bc1c399a \ jars \ classes.jar (;;;;;; **. class)] (Duplicate zip entry [classes.jar: Android / support / v4 / view / ViewPager $ 2.class]))

I use

Android Studio 3.0

Java version: Java (TM) SE Runtime Environment (build 1.8.0_73-b02).

Gradle Version: com.android.tools.build: gradle: 4.1

And I have Multidex enabled

In my application build.gradle file:

android { compileSdkVersion 27 buildToolsVersion '27.0.1' defaultConfig { applicationId "com.drh.bird" minSdkVersion 14 targetSdkVersion 23 aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false compileOptions.encoding = 'ISO-8859-1' multiDexEnabled = true ndk { moduleName "player_shared" } } android { useLibrary 'org.apache.http.legacy' } sourceSets { main { jni.srcDirs = [] } } buildTypes {} android { defaultConfig { multiDexEnabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { compile 'com.android.support:multidex:1.0.1' compile 'com.google.android.gms:play-services:+' compile files('libs/dagger-1.2.2.jar') compile files('libs/javax.inject-1.jar') compile files('libs/nineoldandroids-2.4.0.jar') compile files('libs/support-v4-19.0.1.jar') } 
+5
source share
3 answers
 implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support:design:27.1.0' implementation 'com.android.support:support-v4:27.1.0' implementation 'com.android.support:recyclerview-v7:27.1.0' 

upgrade your entire support library to 27.1.0 as above and remove duplicates

+4
source

You are trying to use compile files('libs/support-v4-19.0.1.jar') with compileSdkVersion 27 . But the support library should have a major version equal to compileSdkVersion

Use implementation "com.android.support:support-v4:27.0.1" instead

Also, never use + in the dependency version. You may get some problems when the dependency is updated.

+1
source

This is because your support library is in conflict. You should always use the same version code for compileSdkVersion , buildToolsVersion , targetSdkVersion and support library .

You should not use jar file with

 compile files('libs/support-v4-19.0.1.jar') 

Instead, you need to use the support library that matches your compileSdkVersion as follows:

 implementation 'com.android.support:support-v4:27.1.0' 

You also need to use the exact version of the game service and make sure that you are using a specific individual API. Not this way:

 compile 'com.google.android.gms:play-services:+' 

But something like this:

 // if you're using only ads implementation 'com.google.android.gms:play-services-ads:12.0.0' 

this will make your method smaller, and then you can remove the multidex.

In the end, your build.gradle should be something like this:

 android { compileSdkVersion 27 buildToolsVersion '27.0.1' defaultConfig { applicationId "com.drh.bird" minSdkVersion 14 targetSdkVersion 27 aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false compileOptions.encoding = 'ISO-8859-1' //multiDexEnabled = true ndk { moduleName "player_shared" } } android { useLibrary 'org.apache.http.legacy' } sourceSets { main { jni.srcDirs = [] } } buildTypes {} android { defaultConfig { //multiDexEnabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } } dependencies { //compile 'com.android.support:multidex:1.0.1' implementation 'com.google.android.gms:play-services:play-services-ads:12.0.0' implementation 'com.android.support:support-v4:27.1.0' compile files('libs/dagger-1.2.2.jar') compile files('libs/javax.inject-1.jar') compile files('libs/nineoldandroids-2.4.0.jar') //compile files('libs/support-v4-19.0.1.jar') } 
0
source

Source: https://habr.com/ru/post/1273454/


All Articles