android - react 原生安卓 "Program type already present: com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil"

标签 android react-native

我们只需升级一个包,就会发生这种情况。它适用于 IOS 部分,但不适用于 android 部分。我尝试排除此类但无济于事有没有办法从包中解散此类?我搜索相同的问题但无济于事我试图回滚但我们有需要新包的更改

应用程序/build.gradle

    apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile



project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"


def enableHermes = project.ext.react.get("enableHermes", false);

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.ginko.ginko"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        missingDimensionStrategy 'react-native-camera', 'general'
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            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 =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }

        }

    }
}

dependencies {
    compile(project(':react-native-nearby-api')) {
         exclude group: 'com.google.android.gms'
    }
    implementation project(':react-native-contacts')
    implementation (project(':@react-native-community_async-storage')){
        exclude group: 'com.reactnativecommunity.asyncstorage.AsyncStorageErrorUtil'
    }
    implementation (project(":react-native-device-info"))
    implementation project(':@react-native-community_geolocation')
    implementation project(':react-native-permissions')
    implementation project(':react-native-camera')
    implementation (project(':react-native-ble-plx')){
        exclude group: 'com.reactnativecommunity.asyncstorage.AsyncStorageErrorUtil'
    }
    implementation project(':react-native-linear-gradient')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01' // for react-native-screens
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02' // for react-native-screens
    // implementation project(':WebRTCModule')
    implementation 'com.google.android.gms:play-services-nearby:17.0.0'

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }
}

// 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 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"
apply plugin: 'com.google.gms.google-services'
// googleServices { disableVersionCheck = true }

最佳答案

这是因为您自己已经链接了库,只需运行以下命令:

react-native unlink @react-native-community/async-storage
或者
npx react-native unlink @react-native-community/async-storage

关于android - react 原生安卓 "Program type already present: com.reactnativecommunity.asyncstorage.AsyncLocalStorageUtil",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61743155/

相关文章:

react-native - 在 React Native 中从 Google Places Autocomplete 获取经纬度

java - 设置内容 View 层次结构

java - Libgdx 和 Android NFC

javascript - 如何使用 React Native 创建发光动画

react-native - 博览会日历 createEventAsync 不工作

ios - 样式输入占位符 R

android - 使用 Gradle : Class XYZ is not accessible through the ClassLoader 为多模块项目设置 SonarQube 5.4

iphone - 基于接近度的设备通信或通知

android - 获取 Android 应用程序中的日历资源列表?

javascript - 如何使用普通 JavaScript 和/或状态生成 future 日期?