gpt4 book ai didi

android - androidx 迁移后,react-native 应用程序上出现 SwipeRefreshLayout 错误

转载 作者:行者123 更新时间:2023-12-02 18:58:40 34 4
gpt4 key购买 nike

刚刚将我的应用程序迁移到 androidx,无法解决此错误。我在 npx react-native run-android 执行结束时收到它,这破坏了应用程序。错误看起来像这样:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/swiperefreshlayout/widget/SwipeRefreshLayout;
at com.facebook.react.shell.MainReactPackage.createViewManagers(MainReactPackage.java:351)
at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:756)
at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:170)
at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:53)
at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:128)
at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:125)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:61)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1173)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1143)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1085)
at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:117)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:916)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.swiperefreshlayout.widget.SwipeRefreshLayout" on path: DexPathList[[zip file "/data/app/com.app-Of8EHYbtm9-YItGtnh8O9Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.app-Of8EHYbtm9-YItGtnh8O9Q==/lib/x86, /data/app/com.app-Of8EHYbtm9-YItGtnh8O9Q==/base.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
...

我尝试过清理、重建、使用依赖版本等方法,但无法克服这一问题。

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "app-name"
minSdkVersion 16
targetSdkVersion 28
versionCode 2097177
versionName "2.0"
multiDexEnabled true

ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty("my-release-key.keystore")) {
storeFile file("my-release-key.keystore")
storePassword "quince"
keyAlias "quince"
keyPassword "quince"
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}

ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "16.0.0"
googlePlayServicesVisionVersion = "17.0.2"
}


dependencies {
implementation project(':react-native-billing')
// def supportLibVersion = project.hasProperty('supportLibVersion') ? project.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION
// def googlePlayServicesVersion = project.hasProperty('googlePlayServicesVersion') ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
// def firebaseVersion = project.hasProperty('firebaseVersion') ? project.firebaseVersion : DEFAULT_FIREBASE_MESSAGING_VERSION

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.annotation:annotation:1.1.0"
//implementation "io.branch.sdk.android:library:3.0.0"
implementation project(':react-native-image-picker')
implementation project(':react-native-branch')
implementation project(':react-native-push-notification')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-wheel-picker')
implementation project(':react-native-svg')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'//26.1.0

implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
implementation "com.facebook.react:react-native:+" // From node_module

implementation "com.google.android.gms:play-services-base:16.0.1"
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services'

这是我的 build.gradle 文件。我真的不知道在这里做什么。滑动刷新工作正常,直到 androidx 迁移。

我非常感谢任何有用的信息或建议。

最佳答案

我找到了解决方案。问题与react-native-screens有关。

将以下两行添加到 android/app/build.gradle 的依赖项部分。

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'

https://github.com/kmagiera/react-native-screens#usage-with-react-navigation-without-expo

CR:https://github.com/react-navigation/react-navigation/issues/6267#issuecomment-528883756

关于android - androidx 迁移后,react-native 应用程序上出现 SwipeRefreshLayout 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56901873/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com