执行任务“:react-native-camera:generateGeneralDebugRFile”失败,并且生成失败

kzmpq1sx  于 2022-12-14  发布在  React
关注(0)|答案(2)|浏览(292)

x1c 0d1x这是我遇到的错误...

安卓/构建版本.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" } 
    }
}

这是我的包.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"
  }
}

应用程序/构建版本.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)

我所尝试的...

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

c9qzyr3d1#

在android/build.gradle的存储库标签中

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

zsbz8rwp2#

如果您的应用程序在此之前运行良好,请按照以下步骤进行检查
1.恢复之后所做的所有更改(如果更改了sdk、gradle、java、react-native等版本)
1.删除node_modules
1.删除构建文件夹(android/buildandroid/app/build
1.如果react-native版本与之前的版本相同,则重新检查package.json
1.运行npm installyarn以安装软件包
1.清理(删除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
          }
    }
    // ...  
}

参考:Fix and updates on Android build failures happening since Nov 4th 2022 #35210

相关问题