简体   繁体   English

NoClassDefFoundError如何突然发生?

[英]How can a NoClassDefFoundError suddenly happen?

All of a sudden, without playing with the gradle file, from one compilation to another, I got this error: 突然间,没有玩gradle文件,从一个编译到另一个编译,我得到了这个错误:

java.lang.RuntimeException: An error occured while executing doInBackground()

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLInputFactory;

Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLInputFactory" on path: DexPathList[[zip file "/data/app/com.vuzix.automation.dev-2/base.apk"],nativeLibraryDirectories=[/data/app/com.vuzix.automation.dev-2/lib/arm, /vendor/lib, /system/lib]]

Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
  1. I tried to disable Instant Run # not working 我试图禁用Instant Run#无法正常工作

  2. I tried to delete app, clean, recompile # not working 我试图删除应用程序,清理,重新编译#不工作

  3. I even updated do Android Studio 3.4 and gradle class path to 'com.android.tools.build:gradle:3.4.0' 我甚至更新了Android Studio 3.4和gradle类路径到'com.android.tools.build:gradle:3.4.0'

My gradle file: 我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.vuzix.automation.dev"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    maven {
        url "https://nexus-repository.snips.ai/repository/snips-maven-releases/"
    }
}
configurations {
    all*.exclude group: "xmlpull", module: "xmlpull"
    all*.exclude group: "org.apache.commons", module: "commons-compress"
    all*.exclude group: "com.thoughtworks.xstream", module: "commons-compress"
}

android {
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    implementation 'com.vuzix:hud-actionmenu:1.1'
    implementation 'com.vuzix:hud-resources:1.1'
    implementation files('libs/core-1.58.0.0.jar')
    implementation files('libs/prov-1.58.0.0.jar')
    implementation files('libs/bcpkix-jdk15on-1.58.0.0.jar')
    implementation files('libs/prosys-opc-ua-sdk-client-server-evaluation-4.0.0-774.jar')
    implementation files('libs/slf4j-api-1.7.25.jar')
    implementation files('libs/slf4j-log4j12-1.7.7.jar')
    implementation files('libs/log4j-1.2.17.jar')
    implementation('ai.snips:snips-platform-android:0.62.3@aar') {
        transitive = true
    }


    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    ['boofcv-android', 'boofcv-core'].each {
        String a -> api group: 'org.boofcv', name: a, version: '0.31'
    }
    api fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
}

Why is this happening? 为什么会这样?

I found out how to resolve the issue, even though I'm still wondering why it worked before. 我发现了如何解决这个问题,尽管我仍然想知道为什么它之前有用。

I downloaded the com.bea.stax.impl_1.2.0.jar and the stax-api-1.0-2.jar and put them in the libs folder. 我下载了com.bea.stax.impl_1.2.0.jarstax-api-1.0-2.jar并将它们放在libs文件夹中。 Then added the jars in File → Project Structure → Dependencies. 然后在文件→项目结构→依赖项中添加了罐子。

Clean, build, run—and voilà it worked. 清洁,构建,运行 - 并且有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM