Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug' android studio

前端 未结 3 1022
耶瑟儿~
耶瑟儿~ 2020-12-20 22:59

I create a game on buildbox I export the project but I can\'t start the game on android studio My problem is that I can\'t run the application or produce an apk file

<
3条回答
  •  眼角桃花
    2020-12-20 23:41

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

    You should not using a jar file with

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

    Instead you need to use support library that matching with your compileSdkVersion like this:

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

    You also need to use an exact version of play service and make sure you are using specific individual API. Not like this:

    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 count small 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')
    }
    

提交回复
热议问题