哦,我多么讨厌这个错误。
我得到了可怕的dexDebug错误,但这次我不知道如何修复它。
确切的错误是:
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42300Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.util.ExceptionWithContext
at com.android.dex.util.ExceptionWithContext.withContext(ExceptionWithContext.java:45)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:369)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)
at com.android.dx.command.dexer.Main.processClass(Main.java:729)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:170)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: java.lang.NullPointerException
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:87)
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:75)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:271)
... 24 more
...while processing <init> (Lcom/appzylabs/pratik/dailydeals/WebFragment;)V
...while processing com/appzylabs/pratik/dailydeals/WebFragment$1.class
1 error; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_71\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 16.398 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
我只有两个依赖项和一个相当干净的app.gradle,如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appzylabs.pratik.dailydeals"
minSdkVersion 8
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:23.0.0'
}
以下是我试图解决的问题,但无济于事: 1)我包括了JSoup的jar,但我删除了它。没有帮助。 2)我添加了multidex支持(multiDexEnabled true)和android:name =&#34; android.support.multidex.MultiDexApplication&#34;在我的AndroidManifest.xml中。纳达。 3)我做了一个干净/构建,并清除缓存并重新启动android studio。什么都没有。
请注意,仅当我尝试运行asyncTask时才会发生这种情况。如果我注释掉那条线就会像魅力一样编译:
new MyLoadWebView().execute("");
问题是什么?有人可以帮忙吗?
答案 0 :(得分:0)
好的,基于Android dex issue: nested class + final boolean : com.android.dex.util.ExceptionWithContext,我认为我为异步任务创建的内部类有问题。所以我所做的是将AsyncTask的类声明从私有更改为public:
private class MyLoadWebView extends AsyncTask<String, Void, Void> { ..
到
public class MyInnerLoadWebView extends AsyncTask<String, Void, Void> { ..
它有效!!!!
我仍然不知道为什么会这样,但似乎是一个严重的错误。有什么意见吗?