我正面臨着這個似乎無法解決的問題。這裏是場景:針對具有ABI分割的特定體系結構的Gradle依賴關係
Im建築apk使用gradle依賴關係和這個依賴關係是特定的體系結構所以對於x86的x86我需要不同的依賴關係和不同的手臂。
我的產品口味解決它:
productFlavors {
dev { ... }
develx86 { ... }
production { ... }
productionx86 { ... }
}
於是我這樣定義的依賴性:
develCompile 'dependency_for_arm'
develx86Compile 'dependency_for_x86'
這工作不錯。但最近我不得不在我的應用程序中添加一個renderscript的用法。我做了這樣:
renderscriptTargetApi 22
renderscriptSupportModeEnabled true
並在此之後,當我上傳到谷歌的apk發揮它說,它的APK是適合與ARM,X86。我不知道這是可能的。正如你可以認爲它會在具有不同CPU的設備上崩潰(如果我爲arm生成apk並且用戶將在x86應用程序上執行它將崩潰)。
所以我decited使用ABI分裂:
splits {
abi {
enable true
reset()
include 'armeabi', 'x86'
universalApk false
}
}
//Ensures architecture specific APKs have a higher version code
//(otherwise an x86 build would end up using the arm build, which x86 devices can run)
ext.versionCodes = [armeabi:0, x86:1]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
output.versionCodeOverride = android.defaultConfig.versionCode + abiVersionCode
}
但現在,當我看到生成APK文件,我的依賴性是當我打開部分風味特異沒有納入APK和APK會崩潰它使用來自這個依賴關係的API。
有人知道如何解決這個問題嗎?或者有人知道爲什麼Google Play會說當我包含renderscript時apk同時適用於兩種體系結構? (沒有它,它正常工作,但我需要renderscript)。
謝謝你的時間。我會感謝任何幫助。
任何運氣?如果你找到答案,請發佈答案 –