我看到類似的問題,但未找到接受的答案。 問題 - 我有我自己的一些小函數的android庫。 我的圖書館使用他人 - f.e. Hawk(沒有sql數據庫)。 我的圖書館gradle文件:Android aar庫不包含依賴關係
apply plugin: 'com.android.library'
buildscript {
repositories {
maven { url "https://www.jitpack.io" }
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'library.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.github.orhanobut:hawk:1.23'
testCompile 'junit:junit:4.12'
}
圖書館工作正常。如果我在另一個項目中使用它作爲項目 - 它也可以工作。但是當我生成*.aar
文件(與gradle
- >assembleRelease
)幷包括到單獨的項目 - 它失敗。項目只看到我的圖書館的類。 Hawk com.orhanobut.hawk包和ofc其他(如果我將使用)不可見。所以ClassNotFoundException
來了。 如果我刪除
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'library.pro'
結果並沒有改變。 我試圖將下面一行添加到proguard的文件(library.pro)
-keep class com.orhanobut.hawk {public *;}
-keep class com.orhanobut.hawk.* {public *;}
結果是相同的。
所以我有兩個問題: 1 - 我該怎麼做才能讓我的主項目看到我的圖書館的第三方依賴關係? 2 - 是可以混淆我的圖書館的代碼(只有我的,而不是依賴)?
奧奇,你能提供一個幫助鏈接嗎? – TooLazy
@TooLazy這裏一個帖子:https://medium.com/prismapp/publishing-android-library-to-bintray-ba588184b690 –