[英]App getting crash immediately after launch in android - React-native
我將 RN 版本 0.64 更新為 0.67,在添加該應用程序后立即啟動后崩潰,沒有任何錯誤,請幫我解決問題
我跑了 adb logcat --buffer=crash
08-02 00:48:57.646 8869 8869 E AndroidRuntime: FATAL EXCEPTION: main 08-02 00:48:57.646 8869 8869 E AndroidRuntime: Process: com.tapp, PID: 8869 08-02 00:48:57.646 8869 8869 E AndroidRuntime:java.lang.NoClassDefFoundError:解析失敗:Landroidx/core/view/OnReceiveContentViewBehavior; 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1530) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at androidx.appcompat.app. AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1614) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069) 08-02 00:48:57.646 8869 8869 E AndroidRuntime : at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:999) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963) 08-02 00:48 :57.646 8869 8869 E AndroidRuntime: 在 android.view.LayoutInflater.inflate(LayoutInflater.Z 93F725A07423FE1C889F448B33D21F46Z:661) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:536) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.view. LayoutInflater.inflate(LayoutInflater.java:479) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:2173) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2671) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.originalInstallDecor( PhoneWindow.Z93F725A07423 FE1C889F448B33D21F46Z:2753) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2735) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2120) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.ActivityTransitionState.setEnterActivityOptions(ActivityTransitionState.java:171) 08-02 00 :48:57.646 8869 8869 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8123) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java: 8083) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3493) 08- 02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3692) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute( LaunchActivityItem.java:85) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at ZC31B32364CE19CA8FCD150A417 ECCE58Z.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2142) 08-02 00 :48:57.646 8869 8869 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.os.Looper.loop(Looper.java: 236) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7864) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at java.lang.reflect. Method.invoke(Native Method) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.ZC31B32364CE19CA8FCD150 A417ECCE58Z.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: 由: java.lang.ClassNotFoundException: 沒有找到 class "androidx.core.view.OnReceiveContentView" ~~TvRq8yhbRZPMs3xyzJ7jGA==/com.tapp-xotKQaDfq4sZ-tA54NPe6w==/base.apk"],nativeLibraryDirectories=[/data/app/~~TvRq8yhbRZPMs3xyzJ7jGA==/com.tapp-xotKQaDfq4sZ-tA54NPe6w==lib /data/app/~~TvRq8yhbRZPMs3xyzJ7jGA==/com.tapp-xotKQaDfq4sZ-tA54NPe6w==/base.apk,/lib/arm64-v8a, /system/lib64: /system/system_ext/lib64]] 08-02 00: 48.57:646 8869 8869 E Android 運行時。 在 dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader:java:207) 08-02 00:48.57:646 8869 8869 E AndroidRuntime。 在 java.lang.ClassLoader.loadClass(ClassLoader:java:379) 08-02 00:48.57:646 8869 8869 E AndroidRuntime。 在 java.lang.ClassLoader.loadClass(ClassLoader:java:312) 08-02 00:48.57:646 8869 8869 E AndroidRuntime。 ... 29 更多
應用程序/build.gradle
apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
import com.android.build.OutputFile
project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
def nativeArchitectures =
project.getProperties().get("reactNativeDebugArchitectures")
plugins {
id 'com.android.application'
}
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
// compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_8
// targetCompatibility JavaVersion.VERSION_1_8
// }
defaultConfig {
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.3.1' }
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0'
}
}
applicationId "com.tapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "19.0"
missingDimensionStrategy 'react-native-camera', 'general'
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal
APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
if (nativeArchitectures) {
ndk {
abiFilters nativeArchitectures.split(',')
}
}
}
release {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
}
dependencies {
implementation 'com.facebook.fresco:animated-base-support:1.3.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-
core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(path: ':library')
implementation platform('com.google.firebase:firebase-bom:29.0.4')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
debugImplementation("com.facebook.flipper:
flipper:${FLIPPER_VERSION}"
)
{
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-
plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.implementation
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-
platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-
icons/fonts.gradle"
我能給出的最佳建議是 go 通過此遷移幫助程序鏈接,並確保所有文件都已相應調整。
https://react-native-community.github.io/upgrade-helper/?from=0.64.0&to=0.67.0
我認為問題出在 andoidx.appcompat class 未找到
在應用程序 build.gradle 中,我更改了這行依賴項:
implementation 'androidx.appcompat:appcompat:1.4.1'
或查看版本
implementation 'com.android.support:support-v4:20.0.+'
我的 build.gradle (項目)中有以下代碼
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'com.android.support:support-v4:20.0.+'
但我目前正在使用 react native 0.68.2。
嗨,我可以通過將這些行添加到 build.gradle 文件來解決我的崩潰問題
應用程序/build.gradle
defaultConfig {
configurations.all {
resolutionStrategy { force 'androidx.core:core:1.5.0' }
}
{...}
}
{....}
dependencies {
implementation ("androidx.appcompat:appcompat:1.3.1") {
version {
strictly '1.3.1'
}
}
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.