当我在android studio中生成签名的APK时,我得到了DexException

直到我对代码进行了一些更改并尝试重新生成签名的APK之前,所有事情都很好。现在,当我尝试在android studio中生成代码时,我得到以下例外:当我在android studio中生成签名的APK时,我得到了DexException

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. 

> com.android.build.api.transform.TransformException:

com.android.ide.common.process.ProcessException:

java.util.concurrent.ExecutionException: com.android.dex.DexException:

Multiple dex files define Lcom/commonsware/cwac/provider/StreamStrategy;

这个例外对我而言是新鲜事。这是我的gradle文件和依赖关系

apply plugin: 'com.android.application' 

android {

compileSdkVersion 25

buildToolsVersion "25.0.2"

aaptOptions {

noCompress 'pdf'

}

useLibrary 'org.apache.http.legacy'

defaultConfig {

applicationId "com.user.plansmart"

minSdkVersion 15

targetSdkVersion 25

versionCode 23

versionName "1.2.6"

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 files('D:/AndroidStudioProjects/PlanSmart/libs/itextpdf-5.4.0.jar')

compile files('D:/AndroidStudioProjects/PlanSmart/libs/cwac-provider-

0.5.2.jar')

compile files('D:/AndroidStudioProjects/PlanSmart/libs/volley.jar')

compile 'com.android.support:appcompat-v7:25.3.1'

compile 'com.android.support:design:25.3.1'

compile 'com.google.android.gms:play-services-ads:11.2.0'

compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'

compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'

compile 'com.commonsware.cwac:provider:0.5.2'

compile 'com.mcxiaoke.volley:library:1.0.1'

testCompile 'junit:junit:4.12'

}

错误的原因是什么?我无法弄清楚。谁能帮我吗。

回答:

从build.gradle中的依赖关系中删除行compile files('D:/AndroidStudioProjects/PlanSmart/libs/cwac-provider-0.5.2.jar')

您已将其定义为compile 'com.commonsware.cwac:provider:0.5.2'

回答:

在gradle这个文件中添加此

configurations { 

compile.exclude group: 'com.commonsware' , module:'cwac'

}

回答:

添加multiDexEnabled true到defaultConfig块内的gradle的文件:

defaultConfig { 

applicationId "com.user.plansmart"

minSdkVersion 15

targetSdkVersion 25

versionCode 23

versionName "1.2.6"

multiDexEnabled true

testInstrumentationRunner

"android.support.test.runner.AndroidJUnitRunner"

}

回答:

gradle文件中添加此行。

defaultConfig { 

applicationId "com.user.plansmart"

minSdkVersion 15

targetSdkVersion 25

versionCode 23

versionName "1.2.6"

multiDexEnabled true

}

希望这会有所帮助。

以上是 当我在android studio中生成签名的APK时,我得到了DexException 的全部内容, 来源链接: utcz.com/qa/262929.html

回到顶部