android - Volley ClassNotFoundException com.android.volley.Response$Listener
问题描述
我为网络 API 编写了一个模块,以便将其导入 2 个应用程序中。在这个模块中,我使用凌空。我第一次生成 module.aar 并将其导入其他项目时,它可以工作。现在,我有运行时错误
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/Response$Listener;
我有:
通过 ./gradlew clean 清理应用和模块
在 proguard 模块文件中添加
-keep 类 com.android.volley.Response { *; } -keepclassmembers 类 com.android.volley.Response { *; } -keepclassmembers 类 com.android.volley.Response$Listener { *; } -keep 类 com.android.volley.Response$Listener { *; }
在网络模块的调试配置模式下禁用 proguard
这没什么好,我在初始化 Volley 时仍然收到 NoClassDefFoundError。
模块的gradle文件是:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
debuggable true
minifyEnabled false
useProguard false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.android.volley:volley:1.1.0'
}
谢谢!
解决方案
推荐阅读
- php - 下载前检查有效/活动 URL - Laravel 7
- excel - 使用 vba 自动过滤一列,其中值来自不同工作表上的不同列
- python - 为什么 Tensorflow 的 Conv2D 权重的维度与 Pytorch 不同?
- java - Maven 找不到类,但正在其他开发人员环境中工作
- c++ - GCC 中的 `movaps` 与 `movups`:它是如何决定的?
- android - 在android RecyclerView中与linearLayoutManager.setreverselayout一起使用时adapter.notifyItemInserted(position == 0)没有动画?
- algorithm - 如何使用 BFS 在未加权和无向图中的两个顶点之间找到 1 个以上的连续最短路径?
- cakephp - Cakephp 4 Windows 安装问题
- python - CNN 音频分类器训练了 3 个类,预测的总和应该小于 1
- r - image_append 变量的动态数量