React Native Android启用Desugaring后启动崩溃求助
启用Core Library Desugaring后React Native应用在Pax A910设备上崩溃
我正在为Pax SmartPOS(A910型号)开发基于Zoop SmartPOS SDK的应用,由于设备仅支持Android SDK 23,必须启用coreLibraryDesugaringEnabled来支持Java Time API中的Instant类。
但启用Desugaring后应用无法启动,崩溃时抛出以下错误:
Failed to register native method com.facebook.react.devsupport.CxxInspectorPackagerConnection$WebSocketDelegate.didFailWithError(Ljava/util/OptionalInt;Ljava/lang/String;)V in /data/app/com.zoop-2/base.apk
完整报错轨迹已留存,我尝试过降级Gradle版本等方法,均未解决问题。
app模块build.gradle代码
apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" react { } def enableProguardInReleaseBuilds = false def jscFlavor = 'org.webkit:android-jsc:+' android { ndkVersion rootProject.ext.ndkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileSdk rootProject.ext.compileSdkVersion namespace "com.zoop" defaultConfig { applicationId "com.zoop" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 1 versionName "1.0" } signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } release { signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } packagingOptions { jniLibs { useLegacyPackaging = true } } compileOptions { coreLibraryDesugaringEnabled = true } } repositories { mavenLocal() maven { url = uri("https://maven.pkg.github.com/getzoop/zoop-package-public") credentials { username = "" // Seu usuário do GitHub. password = "" // Sua PAT do GitHub. } } } dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") implementation("br.zoop.pos.plugin:smartpos-pax-a910:1.8.2") implementation("org.jetbrains.kotlin:kotlin-reflect:1.9.22") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") implementation "com.google.code.gson:gson:2.10" implementation("com.squareup.okhttp:okhttp:2.5.0") implementation("com.squareup.okhttp3:okhttp:4.10.0") coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
根模块build.gradle代码
buildscript { ext { buildToolsVersion = "34.0.0" minSdkVersion = 23 compileSdkVersion = 34 targetSdkVersion = 34 ndkVersion = "26.1.10909125" kotlinVersion = "1.9.22" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } apply plugin: "com.facebook.react.rootproject"
内容的提问来源于stack exchange,提问作者Anderson Vanzo
相关产品推荐
相关产品推荐

