繁体   English   中英

任务 ':react-native-camera:generateGeneralDebugRFile' 执行失败。 并构建失败

[英]Execution failed for task ':react-native-camera:generateGeneralDebugRFile'. and Build Failed

这是我面临的错误...... 这是我面临的错误......

android/build.gradle

   buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.2")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {

        mavenCentral()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        google()
        maven { url 'https://www.jitpack.io' }
        maven { url "https://maven.google.com" } 
    }
}

这是我的 Package.json

{
  "name": "Fastlane",
  "version": "1.3.0",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.15.15",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/clipboard": "^1.5.1",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/drawer": "^6.1.8",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/stack": "^6.0.11",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "axios": "^0.24.0",
    "moment": "^2.29.1",
    "react": "17.0.2",
    "react-native": "0.66.3",
    "react-native-barcode-builder": "^2.0.0",
    "react-native-camera": "^4.2.1",
    "react-native-collapsible": "^1.6.0",
    "react-native-date-picker": "^4.1.3",
    "react-native-flash-message": "^0.2.0",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^2.0.0",
    "react-native-html-to-pdf": "^0.12.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-marquee": "^0.3.2",
    "react-native-material-menu": "^2.0.0",
    "react-native-permissions": "^3.2.0",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-qrcode-scanner": "^1.5.4",
    "react-native-reanimated": "^2.2.4",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.10.0",
    "react-native-share": "^7.3.5",
    "react-native-splash-screen": "^3.2.0",
    "react-native-uuid": "^2.0.1",
    "xlsx": "^0.18.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}

应用程序/build.gradle

    def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId "com.fastlane"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        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'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            if (nativeArchitectures) {
                ndk {
                    abiFilters nativeArchitectures.split(',')
                }
            }
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    // 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
            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
            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 fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules

    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.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
    }
}

// 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.implementation
    into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

我试过的...

  • 我认为解决错误所必需的命令我几乎试图解决......
  • 而且我已经非常正确地设置了环境设置,正如本机设置文档所说的那样......
  • 我已经更新了 gradle 版本、kotlin 版本、react native 版本、npm 版本、node 版本等...
  • 我还更新了 Firebase 应用程序、Firebase 消息和 Firebase .. 其中 Firebase 应用程序和消息版本应该相同......
  • 我还在 Android studio 中设置了 SDK TOOLS,Android SDK ...
  • 我已经卸载了节点,vs 代码并再次重新安装它但再次面临同样的问题,即构建失败....

如果您的应用在此之前运行良好,请按照以下步骤进行检查

  1. 还原之后所做的所有更改(如果您更改了 sdk、gradle、java、react-native 等的版本)
  2. 删除node_modules
  3. 删除构建文件夹( android/build & android/app/build
  4. 如果react-native版本与之前工作的一样,请重新检查package.json
  5. 运行npm installyarn来安装包
  6. 清理(如此处所述删除 gradle 缓存: https ://stackoverflow.com/a/30450020/10657559)并通过将以下更改添加到您的android/build.gradle文件来重建应用程序

 def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) buildscript { //... } allprojects { configurations.all { resolutionStrategy { force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION } } //... }

参考:修复和更新自 2022 年 11 月 4 日以来发生的 Android 构建失败 #35210

在 android/build.gradle 的 repositories 标签中

 maven { url "https://jitpack.io" } 
 maven { url "https://maven.google.com" } 

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM