我创建了一个android库,它的gradle文件中有一些依赖项,如volley,SqlCipher等。当我在另一个项目中使用该库的aar文件时,我得到了ClassNotFoundError w.rt. SqlCipher和Volley。 我认为这可能与称为传递依赖的东西有关。任何人都可以帮我这个吗?
sdk的Gradle文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFile('proguard-rules.pro')
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
mavenCentral()
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'net.zetetic:android-database-sqlcipher:3.4.0'
//compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.google.android.gms:play-services:10.2.0'
}
Gradle for app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.amankush.sdktesting"
minSdkVersion 15
targetSdkVersion 25
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:25.2.0'
compile (project(':sdk-debug'))
}
答案 0 :(得分:0)
您需要在app.gradle build中添加transitive=true
,其中包含aar。
您可以达到以下相同的目的:
compile ('YOUR_GROUP_ID:ARTIFACT_ID:VERSION@aar'){
transitive=true
}