0

我已經創建了一個Android庫,它的gradle文件中有像volley,SqlCipher等特定的依賴關係。當我在另一個項目中使用這個庫的aar文件時,我得到了ClassNotFoundError w.rt. SqlCipher和Volley。 我認爲它可能與一些稱爲傳遞依賴的東西有關。誰能幫我這個?對於SDK傳遞依賴沒有得到體現在Android應用程序

搖籃文件:

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:[email protected]' 
    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' 
} 

搖籃的應用:

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

您需要添加transitive=true你app.gradle建立你在哪裏,包括AAR。

可以達到同樣如下:

compile ('YOUR_GROUP_ID:ARTIFACT_ID:[email protected]'){ 
    transitive=true 
} 
+0

我認爲這僅適用於已發佈的圖書館,我還沒有發表我的圖書館呢。 –

+0

搖籃文件爲應用程式: 依賴性{ 編譯文件樹(包括:[ '的* .jar'],則dir: '庫') testCompile '的junit:junit的:4.12' 編譯「com.android.support:appcompat- V7:25.2.0' 編譯(項目( ':SDK-調試')) } settings.gradle: 包括 ':應用程序', ':SDK-調試' 我已經包含了SDK調試作爲模塊依賴。 –

+0

@AmanKush你可以發佈你的Gradle嗎? –

相關問題