Java 编译和运行[NoClassDefFoundError]时出错
我每天都在犯错误。 当我在android中编译我的项目并在android<5.0中运行时Java 编译和运行[NoClassDefFoundError]时出错,java,android,gradle,android-gradle-plugin,Java,Android,Gradle,Android Gradle Plugin,我每天都在犯错误。 当我在android中编译我的项目并在android
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项目的其余部分,我使用的是口味,如果我把它放在这里,会很长:
defaultConfig {
applicationId "blacktoad.com.flapprototipo"
minSdkVersion 15
targetSdkVersion 23
versionCode 20
versionName "1.48"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
jumboMode = true
}
我下定决心了
我添加了依赖项:compile'com.android.support:multidex:1.0.1'
在我的主要活动中,我添加了:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
我下定决心了
我添加了依赖项:compile'com.android.support:multidex:1.0.1'
在我的主要活动中,我添加了:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
您错过了AndroidManifest.xml中的多索引设置
<application
...
android:name="android.support.multidex.MultiDexApplication"
...
>
当然,您应该在build.gradle中包含该代码
android {
defaultConfig {
multiDexEnabled true
}
}
您错过了AndroidManifest.xml中的多索引设置
<application
...
android:name="android.support.multidex.MultiDexApplication"
...
>
当然,您应该在build.gradle中包含该代码
android {
defaultConfig {
multiDexEnabled true
}
}
通常的android项目有多个build.gradle和一个build.gradle可以有多个
依赖项
部分。您是否可以显示此依赖项部分的位置,以及源文件所在的位置?您是否正在使用proguard混淆您的代码?你添加了所有相关的规则吗?编辑后,我添加了许多其他信息,我只使用project和module gradle。我没有用pro guard禁用我的代码。什么规则?一个普通的android项目有多个build.gradle和一个build.gradle可以有多个依赖项
部分。您是否可以显示此依赖项部分的位置,以及源文件所在的位置?您是否正在使用proguard混淆您的代码?你添加了所有相关的规则吗?编辑后,我添加了许多其他信息,我只使用project和module gradle。我没有用pro guard禁用我的代码。什么规则?