Я пытаюсь использовать Dynami c Доставка внутри моего приложения. Я следовал этой лаборатории Google Code https://codelabs.developers.google.com/codelabs/on-demand-dynamic-delivery/index.html#7, однако я получаю некоторые ошибки.
Ошибка сборки Gradlew В терминале, когда я добавляю следующее команда: ./gradlew build
При запуске в эмуляторе появляется следующее сообщение об ошибке:
app:kaptDebugKotlin FAILED
e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
При работе на реальном устройстве появляется эта ошибка:
Split Install Error(-2): A requested module is not available (to this user/device, for the installed apk)
Ошибка времени выполнения Когда я запускаю приложение и получаю следующую ошибку:
com.google.android.play.core.internal.aa: Failed to bind to the service
Предыдущая ошибка соответствует следующему коду:
val mManager = SplitInstallManagerFactory.create(this)
val request = SplitInstallRequest.newBuilder()
.addModule(view.context.getString(R.string.module_qrscan))
.build()
mManager.startInstall(request)
.addOnCompleteListener {
if (it.isSuccessful) qrScanModuleInstallationMutableLiveData.value = Result.Success(true)
else {
Log.d("QRModule", "The error is: ${it.exception}")
qrScanModuleInstallationMutableLiveData.value = Result.Error(it.exception)
}
}
Это следующий файл gradle из моего Динамический c функциональный модуль
apply plugin: 'com.android.dynamic-feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion versions.compileSDK
defaultConfig {
applicationId "com.tafies.qrscan"
minSdkVersion versions.minSDK
targetSdkVersion versions.targetSDK
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
}
// Required for AR because it includes a library built with Java 8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation project(':app')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
И это следующий файл gradle из моего :app
модуля:
apply plugin: 'com.android.application'
//apply plugin: 'com.google.firebase.appdistribution'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.firebase.firebase-perf' // For Firebase Performance Monitoring
apply plugin: 'com.google.gms.google-services'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'org.jetbrains.dokka-android' // For Dokka documentation
apply plugin: 'io.fabric' // For Crashlytics
// For version name and version code
ext.versionMajor = 1
ext.versionMinor = 2
ext.versionPatch = 1
ext.versionClassifier = null // Indicate if we're classifying the versions for development
ext.isSnapshot = true // Means that the app is in development mode
ext.isAlpha = false // Means that the app is in it's primary testing phase
ext.isBeta = false // Means that the app is in it's secondary testing phase
ext.isRC = false // Means that the app is in release candidate
ext.minimumSdkVersion = 21
android {
compileSdkVersion versions.compileSDK
// Enable data binding
dataBinding {
enabled = true
}
bundle {
density {
// Different APKs are generated for devices with different screen densities; true by default.
enableSplit true
}
abi {
// Different APKs are generated for devices with different CPU architectures; true by default.
enableSplit true
}
language {
// This is disabled so that the App Bundle does NOT split the APK for each language.
// We're gonna use the same APK for all languages.
enableSplit false
}
}
defaultConfig {
applicationId "com.tafies.events"
minSdkVersion versions.minSDK
targetSdkVersion versions.targetSDK
versionCode generateVersionCode()
versionName generateVersionName()
buildConfigField "String", "ALGOLIA_CLIENT_ID", "\"${project.property("algolia_app_id")}\""
buildConfigField "String", "ALGOLIA_SEARCH_ONLY_API_KEY", "\"${project.property("algolia_search_only_api_key")}\""
buildConfigField "String", "STRIPE_PUBLISHABLE_KEY", "\"${project.property("stripe_publishable_key")}\""
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// For testing release mode
// signingConfig signingConfigs.debug // TODO remove this line
// debuggable true // TODO remove this line
// Enables resource shrinking, which is performed by the
// Android Gradle plugin.
// shrinkResources true TODO remove the comment
// Enables code shrinking, obfuscation, and optimization for only
// your project's release build type.
// minifyEnabled true TODO remove the comment
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
FirebasePerformance {
// Set this flag to 'false' to disable @AddTrace annotation processing and
// automatic HTTP/S network request monitoring
// for a specific build variant at compile time.
instrumentationEnabled false
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
dynamicFeatures = [':qrScan']
}
// Generate version code
private Integer generateVersionCode() {
return ext.minimumSdkVersion * 10000000 + ext.versionMajor * 10000 + ext.versionMinor * 100 + ext.versionPatch
}
// Generate version name
private String generateVersionName() {
String versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
if (!ext.versionClassifier) {
if (ext.isSnapshot) {
ext.versionClassifier = "SNAPSHOT"
} else if (ext.isAlpha) {
ext.versionClassifier = "ALPHA"
} else if (ext.isBeta) {
ext.versionClassifier = "BETA"
} else if (ext.isRC) {
ext.versionClassifier = "RC"
}
}
if (ext.versionClassifier) {
versionName += "-" + ext.versionClassifier
}
return versionName
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
.... more libraries
}
kotlin {
apply plugin: 'com.google.gms.google-services'
}