我在Android Studio中實現了一個名爲「proximity」的庫項目,並生成了一個「.aar」。這個aar我已經添加到一個新的測試項目作爲一個模塊,如下所述:https://stackoverflow.com/a/24894387/2791503 此外,我將模塊作爲與傳遞標誌的依賴關係,因爲它已經在這裏提出:https://stackoverflow.com/a/25730092/2791503 這可能是gradle File for新TestProject:AAR傳遞依賴關係Google位置服務
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile(project(':proximity')) {
transitive=true
}
不過,當我啓動應用程序,它告訴我,它無法找到一類谷歌的位置API,這是我的庫模塊的依賴。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
如何強制gradle包含我的庫模塊的傳遞依賴關係?
編輯: 原來這裏是庫項目的gradle這個構建文件:
dependencies {
//integration tests
androidTestCompile 'com.android.support.test:runner:0.4.1'
// Set this dependency to use JUnit 4 rules
androidTestCompile 'com.android.support.test:rules:0.4.1'
// Set this dependency to build and run Espresso tests
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
// Set this dependency to build and run UI Automator tests
androidTestCompile 'com.android.support.test.uiautomator:uiautomator- v18:2.1.2'
androidTestCompile 'com.android.support:support-annotations:23.1.1'
//local unit testing
testCompile 'junit:junit:4.1'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
//estimote sdk
compile 'com.estimote:sdk:[email protected]'
//google location api(GPS)
compile 'com.google.android.gms:play-services-location:8.4.0'
//Google Guave Java Util
compile 'com.google.guava:guava:18.0'
//custom BeSpoon library for android
compile project(':bespoonlibrary')
}
這是gradle這個build文件的外觀導入庫作爲一個模塊引用AAR後:
configurations.create("default")
artifacts.add("default", file('app-release.aar'))
本地android庫項目通常會自動提供它們的依賴關係。 –
聽起來合乎邏輯,但不幸的是,這對我不起作用 –
您是如何定義鄰近庫的依賴關係的? –