問題描述
我用 gradle 更新到了最新版本的 Android studio 2.0 Beta 6:
I updated to the last version of Android studio 2.0 Beta 6 with the gradle :
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
}
該應用在我測試過的所有東西的模擬器和設備上運行良好.
The app works perfectly fine on emulator and devices I tested every thing and it works fine.
我只有在嘗試生成簽名的 APK 時遇到了很多錯誤,
I got many errors only when I try to Generate Signed APK,
我在依賴項中遇到了一些錯誤,當我排除矢量繪圖、矢量動畫繪圖和 Support-v4 庫時,所有這些錯誤都解決了
I got some errors in dependencies, all of them solved when i excluded vector drawable, vector animate drawable and Support-v4 library
現在我沒有任何依賴錯誤.
Now i dont have any dependencies error.
現在我的 app 模塊的 gradle.build 看起來像這樣:
now my gradle.build for the app module looks like this:
apply plugin: 'com.android.application'
android {
configurations {
//all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude module: 'animated-vector-drawable'
all*.exclude module: 'support-vector-drawable'
//all*.exclude module: 'support-v4'
}
repositories {
maven { url "https://jitpack.io" }
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.test.test"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1"
// multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.github.afollestad.material-dialogs:commons:0.8.5.5@aar') {
transitive = true
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile('com.google.android.gms:play-services-ads:8.4.0') {
exclude module: 'support-v4'
}
compile('com.google.android.gms:play-services-analytics:8.4.0') {
exclude module: 'support-v4'
}
compile('com.android.support:appcompat-v7:23.2.0') {
exclude module: 'support-v4'
exclude module: 'animated-vector-drawable'
exclude module: 'support-vector-drawable'
}
compile('com.android.support:support-v4:23.2.0') {
exclude module: 'animated-vector-drawable'
exclude module: 'support-vector-drawable'
}
compile('com.android.support:palette-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:cardview-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:recyclerview-v7:23.2.0') {
exclude module: 'support-v4'
}
compile('com.android.support:design:23.2.0') {
exclude module: 'support-v4'
}
compile('com.nineoldandroids:library:2.4.0') {
exclude module: 'support-v4'
}
compile('com.baoyz.swipemenulistview:library:1.2.1') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile('com.squareup.picasso:picasso:2.5.2') {
exclude module: 'support-v4'
}
compile('com.nononsenseapps:filepicker:2.5.0') {
exclude module: 'support-v4'
exclude module: 'appcompat-v7'
exclude module: 'recyclerview-v7'
}
compile 'com.google.code.gson:gson:2.6.1'
}
只有在我為發布而構建時才會出現錯誤:
The errors shows up only when I build for release:
這是我打開multiDex時的錯誤:
This is the error when i turn on multiDex:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
這是我關閉它時的錯誤:
And this is the error when i turn it off:
:app:transformClassesWithDexForRelease
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
我嘗試將 buildToolsVersion '23.0.2'
更改為所有可能的版本,但沒有任何改變.
I tried to change the buildToolsVersion '23.0.2'
to every possible version and nothing changed.
當我輸入 22.0.1 版本時出現此錯誤:
when i put the version 22.0.1 i got this error:
Error:Error converting bytecode to dex:
Cause: com.android.dx.cf.iface.ParseException: name already added: string{"a"}
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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
我嘗試了所有可能的支持庫版本和相同的結果.
I tried with all possible support libraries version and same result.
我嘗試使用 Java 1.6 和 1.7,但沒有任何改變!
I tried with Java 1.6 and 1.7 and nothing has changed !
請問還有什么其他可能的解決方案?
what can be other possible solution please ?
推薦答案
我也遇到了同樣的錯誤,我正在搜索許多具有重復依賴項或 multidex 等的現有答案,但沒有一個有效.(Android studio 2.0 Beta 6,構建工具 23.0.2,無 multidex)
I also faced the same error, and i was searching through many existing answers with duplicate dependencies or multidex etc. but none worked. (Android studio 2.0 Beta 6, Build tools 23.0.2, no multidex)
原來我曾經使用的包名與清單中描述的包名不匹配.
It turned out that i once used a package names which didn't match the package name that is depicted in the Manifest.
在其他 ParseException 行中,我發現我在不同模塊中有文件,這些文件具有相似的包名稱/路徑,可能會與 dexer 發生沖突.
In other ParseException lines, i found out that i had files in different modules whith similiar package names/paths that possibly conflicted the dexer.
示例:
模塊 A:com.example.xyz.ticketing.modulea.Interface.java
模塊 B:com.example.Xyz.ticketing.moduleb.Enumerations.java
模塊 C:依賴于 A 和 B
Module C: Has dependencies on A and B
將Xyz"修復為小寫后,dexer 又正常了.
After fixing "Xyz" to lowercase, the dexer was fine again.
如何找出:
當我查看 gradle 控制臺的輸出時,ParseExceptions 看起來像這樣:
When i looked through the output of the gradle console for the ParseExceptions that looks like this:
AGPBI: {"kind":"error","text":"將字節碼轉換為 dex 時出錯: 原因:java.lang.RuntimeException: 異常解析類"
AGPBI: {"kind":"error","text":"Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes"
我滾動到接近異常的末尾.在那長長的異常行中有一部分實際上提到了原因:
I scrolled close to the end of the exception. There is a part in that long exception line that actually mentions the cause:
引起:com.android.dx.cf.iface.ParseException:類名(at/dummycompany/mFGM/hata/hwp/BuildConfig)與路徑不匹配(at/dummycompany/mfgm/hata/hwp/BuildConfig.class)
這樣我找到了在哪里搜索不匹配的包名稱/路徑
This way i found out where to search for missmatching package names/paths
這篇關于將字節碼轉換為 dex 時出錯:原因:java.lang.RuntimeException:異常解析類 - Android Studio 2.0 beta 6的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!