简体   繁体   English

androidx 迁移后本机应用程序上的 SwipeRefreshLayout 错误

[英]SwipeRefreshLayout error on a react-native app after androidx migration

Just migrated my app to androidx and cannot work out this error.刚刚将我的应用程序迁移到 androidx 并且无法解决此错误。 I receive it just at the end of npx react-native run-android execution which breaks the app.我在npx react-native run-android执行结束时收到它,这会破坏应用程序。 The error looks like this:错误如下所示:

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)
...

I've tried things like cleaning, rebuilding, played with version of dependencies, but cannot overcome this one.我尝试过清理、重建、使用依赖版本等方法,但无法克服这个问题。

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'

Here's my build.gradle file.这是我的 build.gradle 文件。 I really don't know what to do here.我真的不知道在这里做什么。 The swipe refresh worked fine up untill the androidx migration.滑动刷新工作正常,直到 androidx 迁移。

I'd greatly appreciate any helpful information or advice.我非常感谢任何有用的信息或建议。

I found a solution.我找到了解决方案。 Problem is related to react-native-screens.问题与 react-native-screens 有关。

Add the following two lines to dependencies section in android/app/build.gradle.将以下两行添加到 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 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 CR: https : //github.com/react-navigation/react-navigation/issues/6267#issuecomment-528883756

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 androidX迁移并将react-native升级到0.60.4之后,“包android.support.annotation不存在” - “package android.support.annotation does not exist” after androidX migration and react-native upgrade to 0.60.4 AndroidX 迁移后应用程序崩溃(数据绑定错误) - App crashes (Databinding Error) after AndroidX Migration 在 react-native 中更改为 androidX - Change to androidX in react-native AndroidX 任务后的 React-Native :@react-native-community_viewpager:compileDebugJavaWithJavac FAILED - React-Native after AndroidX Task :@react-native-community_viewpager:compileDebugJavaWithJavac FAILED 如何避免在react-native中迁移到AndroidX? - How to avoid migrating to AndroidX in react-native? 安装新的 react-native 项目时找不到 swiperefreshlayout-1.0.0.aar 错误 - Could not find swiperefreshlayout-1.0.0.aar error when installing new react-native project AndroidX 迁移后应用在 KitKat 上崩溃 - App crashes on KitKat after AndroidX migration 错误:找不到符号导入androidx.core.widget.SwipeRefreshLayout; 迁移到 androidx 后 - error: cannot find symbol import androidx.core.widget.SwipeRefreshLayout; after migrating to androidx 迁移到 androidx 后错误膨胀类 androidx.constraintlayout.ConstraintLayout - Error inflating class androidx.constraintlayout.ConstraintLayout after migration to androidx 迁移到 androidx 后错误膨胀类 - Error inflating class after migration to androidx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM