0

I have created an android library which has certain dependencies like volley, SqlCipher etc in its gradle file. When I use the aar file for this library in another project, I am getting the ClassNotFoundError w.rt. SqlCipher and Volley. I think it might be related to something called transitive dependency. Can anyone help me with this?

Gradle file for sdk :

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'))

}
Aman Kush
  • 91
  • 2
  • 11

1 Answers1

0

You need to add transitive=true in you app.gradle build where you are including the aar.

You can achieve the same as below:

compile ('YOUR_GROUP_ID:ARTIFACT_ID:VERSION@aar'){
   transitive=true
}
Anurag Singh
  • 6,140
  • 2
  • 31
  • 47
  • I think it works only for the published libraries, I havent published my library yet. – Aman Kush Apr 12 '17 at 10:54
  • Gradle file for app : 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')) } settings.gradle : include ':app', ':sdk-debug' I have included sdk-debug as module dependency. – Aman Kush Apr 12 '17 at 10:57
  • I have added the gradle files for both sdk and app. Please check now if you can help – Aman Kush Apr 12 '17 at 12:52