编译并运行时发生错误[NoClassDefFoundError]

西洛·贝塞拉·毕晓普(SiloéBezerra Bishop)

我在错误中花费了很多天。当我在android中编译我的项目并在Android <5.0中运行时

Caused by: java.lang.NoClassDefFoundError: com.squareup.okhttp.Protocol[]

问题出在“ NoClassDefFoundError”中,因为我删除了很多零件,并且在另一个类中收到了相同的错误。我已经清理了我的项目,使用gradlew clean我用谷歌搜索了很多天。请帮我。

我对gradle的依赖:

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')

compile('com.facebook.android:facebook-android-sdk:[4,5)') {
    exclude group: 'com.parse.bolts',
            module: 'bolts-tasks'
    exclude group: 'com.parse.bolts',
            module: 'bolts-applinks';
}

compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.apis:google-api-services-youtube:v3-rev145-1.20.0'

compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'info.hoang8f:fbutton:1.0.5'
compile 'com.victor:lib:1.0.1'
compile 'com.melnykov:floatingactionbutton:1.3.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.github.amlcurran.showcaseview:library:5.3.0'
compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.5'
compile 'com.facebook.fresco:fresco:0.7.0'
compile 'com.facebook.fresco:imagepipeline-okhttp:0.7.0'
compile 'com.wang.avi:library:1.0.1'
compile 'com.balysv:material-ripple:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.markushi:circlebutton:1.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.github.jd-alexander:LikeButton:0.1.8'
compile 'com.android.support:multidex:1.0.1'
}

[编辑]

模块Gradle:

buildscript {
repositories {
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

该项目的其余部分,我使用的是调味料,如果我放在这里会很长:

defaultConfig {
        applicationId "blacktoad.com.flapprototipo"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 20
        versionName "1.48"

        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
        jumboMode = true
    }
流动之星

您错过了AndroidManifest.xml中的multidex设置

<application
   ...
   android:name="android.support.multidex.MultiDexApplication"
   ...
>

如果您在application标记中已经具有name属性,请在该类中添加以下覆盖函数,以扩展Application而不是AndroidManifest.xml。

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

当然,您应该在build.gradle中包含该代码

android {
    defaultConfig {
        multiDexEnabled true
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

java运行时错误NoClassDefFoundError

运行时错误与编译时错误

为什么正确编译C ++类构造函数后发生运行时错误

NoClassDefFoundError的运行时

Java-什么时候发生编译器错误,什么时候发生运行时异常?

除以0是编译器错误或运行时错误

运行时异常:执行doInBackground()时发生错误

扩展Listadapter时发生运行时错误

投射对象时发生运行时错误

仅在systemd上运行时发生SSL错误

在Scala中使用anorm时发生运行时错误

从逆序C ++访问向量时发生运行时错误

调用方法时发生运行时错误?

USB调试Android时发生运行时错误

SXS:BasepCreateActCtx() BasepSxsCreateStreams() 失败 运行时发生错误

错误:在 Flutter 运行时发生的 Method Not Found

编译 index.cshtml 抛出运行时错误

编译Java运行时库时出现Protobuf错误

运行时与编译时间

Android Studio中.AAR内的类在运行时发生NoClassDefFoundError

使用sbt构建的应用程序在运行时发生NoClassDefFoundError

使用javac编译Java程序成功,但是运行时出现NoClassDefFoundError

尝试访问在VBA(Visio)中在运行时创建的控件的属性时发生运行时错误

LINQ to Entities错误在运行时发生,但未在单元测试中发生

自动内存分配发生在编译时还是在 C 中的运行时?

MongoDB的运行时异常抛出的NoClassDefFoundError

运行时出现AmazonDynamoDBClientBuilder的NoClassDefFoundError

在运行时出现NoClassDefFoundError

为什么此代码编译并在执行时给出运行时错误