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

有些话、适合烂在心里 提交于 2019-11-29 14:43:46
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'

update your all support library to 27.1.0 like above and remove duplicates

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

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

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

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')
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!