【发布时间】:2020-01-30 16:18:17
【问题描述】:
即使在添加依赖项并导入类之后,我仍然收到 java.lang.NoClassDefFoundError: com.squareup.okhttp.logging.HttpLoggingInterceptor。
有人可以帮忙吗?
Gradle 构建文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xyz"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}
【问题讨论】:
-
你使用的是Android Studio还是eclipse?如果是 Android Studio,你使用的是 Gradle 吗?如果是,您可以将 Gradle 文件添加到您的问题中吗?
-
@cricket_007 已添加构建文件
-
你能成功使用Gradle构建并检查所有的依赖都下载了吗?
-
如何知道它是否正在下载依赖项,对不起,我是android新手。 @cricket_007
-
没关系。在 Android Studio 的其中一个侧面板中,应该有一个带有绿色图标的 Gradle 按钮。从那里,应该有诸如 clean 和 installDependencies 和 build 的选项。然后在另一个窗格中(可能是您的文件所在的左侧),可能有一个用于引用库的折叠部分。