gpt4 book ai didi

java - 编译运行时出错[NoClassDefFoundError]

转载 作者:行者123 更新时间:2023-12-02 03:43:41 25 4
gpt4 key购买 nike

我在错误中度过了很多天。当我在 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
}

项目 gradle 的其余部分,我正在使用 flavor ,如果我放在这里将会很长:

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"
...
>

如果您已经在应用程序标签中添加了 name 属性,请在该类中添加以下覆盖函数,以扩展 Application 而不是 AndroidManifest.xml。

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

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

android {
defaultConfig {
multiDexEnabled true
}
}

关于java - 编译运行时出错[NoClassDefFoundError],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36550737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com