系統:執行失敗的任務,了java.lang.RuntimeException:無法預DEX
- 的Windows7的x86(32位)
- JDK 1.8.0_131
- AndroidStudio 2.3.2
我正試圖將APP部署到我的Android設備中,但一直面臨此錯誤:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
java.lang.RuntimeException:
java.lang.RuntimeException:
Unable to pre-dex 'C:\Users\me\.android\build-cache\7529f6ca1b923c48febb00ef8a29431fc2b1b32b\output\jars\classes.jar' to
'D:\Data\MyAPP\code\Android\app\build\intermediates\transforms\dex\debug\folders\1000\10\classes_db0da3bb5cf7139810a8b2f028705f64cb610b31'
讀多線程後從谷歌&#1,我嘗試了所有的以下解決方案:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'
def AAVersion = '4.0.0'
def supportVersion = '23.4.0'
android
{
compileSdkVersion 23
buildToolsVersion '25.0.0'
packagingOptions
{
exclude 'META-INF/ASL2.0'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
defaultConfig
{
applicationId "app.myapp.com."
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "v1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions
{
javaMaxHeapSize "2g" // set it to 4g will bring unable to start JavaVirtualMachine
preDexLibraries = false
}
compileOptions
{
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
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'
})
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
apt "org.androidannotations:otto:$AAVersion"
compile "org.androidannotations:rest-spring-api:$AAVersion"
apt "org.androidannotations:rest-spring:$AAVersion"
/** http://projects.spring.io/spring-android/ */
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
compile 'com.android.support:multidex:1.0.1'
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:design:$supportVersion"
compile "com.android.support:percent:$supportVersion"
compile "com.android.support:recyclerview-v7:$supportVersion"
compile 'com.google.android.gms:play-services-gcm:10.2.4'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile 'com.fasterxml.jackson.core:jackson-core:2.8.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.1'
//Event Bus: https://github.com/square/otto
compile 'com.squareup:otto:1.3.8'
compile 'me.dm7.barcodescanner:zbar:1.9'
testCompile 'junit:junit:4.12'
}
apt
{
arguments
{
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
// you should set your package name here if you are using different application IDs
// resourcePackageName "your.package.name"
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
清潔和重建我的項目
,但沒有幫助我解決這個問題......任何人都可以給出更多建議?
我期待着您的回覆,謝謝您〜
你能後的完整文件的gradle? – Sac
完成build.gradle文件過帳,並且我嘗試過啓用multiDenEnabled爲true,但仍然不起作用... – RRTW
嘗試將[apply plugin:'com.google.gms.google-services']放在你的gradle文件。 – Sac