簡體   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