【问题标题】:Volley - NoClassDefFoundErrorVolley - NoClassDefFoundError
【发布时间】:2018-04-17 06:41:51
【问题描述】:

我已经参考了其他答案,例如this,但仍然出现以下异常:

E/UncaughtException: java.lang.NoClassDefFoundError: 解析失败:Lcom/android/volley/toolbox/Volley;

这里是依赖:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.google.android.gms:play-services-base:12.0.1'
    implementation 'com.google.android.gms:play-services-location:12.0.1'
    implementation "com.google.firebase:firebase-messaging:15.0.0"
    implementation 'com.google.firebase:firebase-core:12.0.1'
    implementation 'com.android.volley:volley:1.1.0'

    apply plugin: 'maven'
}  

事实上,当我尝试将 Volley 添加为依赖项时,它从未显示在依赖项列表中。而显示其他谷歌库。

注意:我已经检查了其他 StackOverFlow 链接,所以请只有在您绝对确定答案对此正确有效时,请随意标记重复。

【问题讨论】:

  • 您可以从github.com/google/volley 下载 Volley 并作为模块导入到您的项目中,在您的 gradle 文件中,您可以尝试implementation project(':Module_Volley') 其中 Module_Volley 是我的 volley lib 模块名称

标签: android android-studio android-volley


【解决方案1】:

打开命令提示符并重定向到您的项目目录并输入

如果您是 Windows 用户:gradlew.bat clean

如果你是 mac 用户,输入:./gradlew clean

【讨论】:

  • 确保你已经在 build.gradle 的所有项目中添加了 maven
【解决方案2】:

如果您的 targetSdkVersion 介于 26 和 28 之间,请尝试在 AndroidManifest 的应用程序标签中添加 uses-library android:name="org.apache.http.legacy" android:required="false"。第二种方法是:将 volley.jar 导入您的 app/lids 目录,而不是从 gradle 中获取它,而是在 build.gradle 中使用本地 jar 作为 实现文件('libs/volley.jar')在应用模块中

【讨论】:

    猜你喜欢
    • 2014-10-11
    • 1970-01-01
    • 2013-10-19
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2012-09-18
    • 2012-11-11
    • 2015-11-12
    相关资源
    最近更新 更多