今天我遇到了一個大規模的錯誤,不允許我在手機上運行示例項目。Android Studio意外的頂級例外:
當Android的工作室正在建設的項目,它首先說明了以下目標爲UP-TO-DATE
:
....
:demoproject:processDebugResources UP-TO-DATE
:demoproject:generateDebugSources UP-TO-DATE
:demoproject:compileDebugJava UP-TO-DATE
:demoproject:proguardDebug UP-TO-DATE
....
有幾十個在生成過程中這些UP-TO-DATE
日誌報表。然而,他們總是停在:demoproject:dexDebug
。對於dexDebug
,我似乎從未得到UP-TO-DATE
日誌語句。
相反,dexDebug
後跟此錯誤:
:demoproject:dexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.xyz.corp.sample.project.demo.a) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
現在有幾十個,這些Ignoring InnerClasses attribute
錯誤。它們甚至發生在v4支持庫中的類中,這真是令人困惑。
最後,這些錯誤有一個新的語句結尾:
UNEXPECTED TOP-LEVEL EXCEPTION:
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing com/xyz/corp/sdk/AbcSDKConfig.class
1 error; aborting
Error:Execution failed for task ':demoproject:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
...while parsing com/xyz/corp/sdk/AbcSDKConfig.class
1 error; aborting
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
我已經諮詢了以下鏈接:
Gradle finished with non-zero exit value 1。
2.What is the 「Ignoring InnerClasses attribute」 warning output during compilation?。
我不確定它們是否適用於我的情況。我甚至沒有能夠運行該項目。我已將我的IDE更新到SDK Tools 22.0.1,並在我的build.gradle
文件中修改了buildToolsVersion
標記,但無濟於事。有人可以指導我如何處理這個錯誤?所有的幫助將不勝感激。
哦,這裏是我的build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "com.xyz.corp.demo.project"
minSdkVersion 10
targetSdkVersion 22
versionCode 2060200
versionName '2.6.02.00'
}
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
compile project(':xyzSDK')
}
請幫助!
你能重新啓動你的工作室/機器,並重建你的項目 – Sree
什麼是你的Java版本? 1.8?如果是這樣,請回滾到1.7 – Nizam
@NoName:我在錯誤之前描述了日誌:很多很多'UP-TO-DATE'語句。 'dexDebug'檢查沒有得到'UP-TO-DATE'語句;它接着是上面的日誌。這對你來說夠了嗎?不,我還沒有檢查multidex問題呢... –