我更新了RN版本0.64到0.67,在没有任何错误的情况下添加了该应用程序在启动后立即崩溃,请帮助我修复问题。
我运行了亚开行logcat --缓冲区=崩溃
Landroidx/core/view/OnReceiveContentViewBehavior;:
08-02 00:48:57.646 8869 8869 E AndroidRuntime:致命例外:主08-02 00:48:57.646 8869 8869 E AndroidRuntime: AndroidRuntime: com.tapp,PID: 8869 08-02 :48:57.646 8869 8869 E AndroidRuntime: java.lang.NoClassDefFoundError:失败解析:com.tapp08-02 00:48:57.646 8869 8869 E androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1530) AndroidRuntime: at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1614) 08-02 :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.android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963) 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: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.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.originalInstallDecor(PhoneWindow.java:2753) 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.java:2753) 08-02 00:48:57.646 8869 8869 E AndroidRuntime::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 android.app.Activity.performCreate(Activity.java:8083):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) 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 android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85):at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 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 android.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.app.ActivityThread.main(ActivityThread.java:7864) 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(本土法) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at com.android.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 :48:57.646 8869 8869 E AndroidRuntime: AndroidRuntime: on : java.lang.ClassNotFoundException: app class "androidx.core.view.OnReceiveContentViewBehavior“on path: DexPathList[zip file”/data/app/~tvRq8yhbRZPMs3xyzJ7jga==//-tA54NPe6w==/base.apk“,nativeLibraryDirectories=/data/app/TvRq8yhbRZPMs3xyzJ7jGA==/com.tapp-xotKQaDfq4sZ-tA54NPe6w==/lib/arm64,/data/app/TvRq8yhbRZPMs3xyzJ7jGA==/com.tapp-xotKQaDfq4sZ-tA54NPe6w==/base.apk!/lib/arm64-v8a,/system/lib64,64,/system_ext/lib64 64] 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) 08-02 00:48:57.646 8869 8869 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) 08-02 00:48:57.646 8869 8869 E AndroidRuntime:
app/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"
发布于 2022-08-02 03:47:58
我可以给出的最佳建议是,通过这个迁移助手链接,并确保所有文件都进行了相应的调整。
https://react-native-community.github.io/upgrade-helper/?from=0.64.0&to=0.67.0
发布于 2022-08-02 05:58:39
我认为问题是在andoidx.appcompat类中找不到
在app 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原生0.68.2。
发布于 2022-08-02 10:07:39
嗨,我可以通过将这些行添加到build.gradle文件中来解决我的崩溃问题。
app/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'
}
}
谢谢
https://stackoverflow.com/questions/73201690
复制相似问题