Java引入依赖aar,添加gradle依赖库aar包

I am making a library project for a vendor and it needs Android Volley as a dependency. I have used this Create aar file in Android Studio to create the .aar file and to include this in a test project I am using this Adding local .aar files to Gradle build using "flatDirs" is not working. The library is linked fine and there are no errors in the project compilation. But at runtime the test application crashes saying it cannot find Volley

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/volley/toolbox/Volley;

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.android.volley.toolbox.Volley" on path: DexPathList[[zip file "/data/app/in.gridsync.acttest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

My Gradle file for the library project is like this

apply plugin: 'com.android.library'

android {

compileSdkVersion 23

buildToolsVersion "23.0.1"

defaultConfig {

minSdkVersion 14

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')

testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.1.0'

compile 'com.mcxiaoke.volley:library:1.0.19'

}

and in the test project the gradle is this

apply plugin: 'com.android.application'

android {

compileSdkVersion 23

buildToolsVersion "23.0.1"

defaultConfig {

applicationId "in.gridsync.acttest"

minSdkVersion 14

targetSdkVersion 23

versionCode 1

versionName "1.0"

}

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

}

dependencies {

compile project(':openapp-library')

compile fileTree(include: ['*.jar'], dir: 'libs')

testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:23.1.0'

}

I assumed, when the .aar package was created, it'd use and include the dependency it has on Volley library. Can someone please throw some light on this?

解决方案

Far as I know, you must add "@aar" for the .aar libraries. Also the jar file isn't required, it downloads that by itself.

Try this:

compile 'com.mcxiaoke.volley:library:1.0.19@aar'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值