當我在nexus 5設備上構建並運行項目時,它運行良好。但是,當我建立和我的三星GT-I9100(API 16)運行該項目,它顯示的錯誤:apache錯誤:任務':app:transformClassesWithJarMergingForDebug'的執行失敗。 > com.android.build.api
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/apache/http/Consts;
然後我添加multiDexEnabled true
我gradle這個。當我嘗試再次編譯時,現在我收到以下錯誤消息 錯誤:執行任務':app:transformClassesWithDexForDebug'失敗。
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lorg/apache/http/Consts;
,但再次,它工作正常,當我編譯它在我的Nexus 5(API 23)
我的應用程序gradle這個文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.project.example"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:multidex:1.0.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:design:25.1.1'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
}
發表您的品位文件 – Umarov
@Umarov的核實。我編輯了他們 – VincentTheonardo