简体   繁体   English

gradlew assembleRelease 不适用于 react-native-camera

[英]gradlew assembleRelease doesn't work with react-native-camera

I can't build release version of application.我无法构建应用程序的发布版本。 When I write .\gradlew assembleRelease , I get this error Execution failed for task ':react-native-camera:compileGeneralReleaseJavaWithJavac' .当我写.\gradlew assembleRelease时,我收到此错误Execution failed for task ':react-native-camera:compileGeneralReleaseJavaWithJavac' My app/build.gradle file:我的app/build.gradle文件:

apply plugin: "com.android.application"
apply from: "../../node_modules/react-native-vector-icons/fonts.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 enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

def jscFlavor = 'org.webkit:android-jsc:+'

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.ms.showcase"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 200
        versionName "2.0.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'
        }
    }
    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.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
            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 {
    // This should be here already

    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.9"
    implementation "com.google.firebase:firebase-messaging:19.0.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

    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 plugin: 'com.google.gms.google-services'

I tried to search in Google, but I found nothing.我试图在谷歌中搜索,但我一无所获。 My RN version 0.61.我的 RN 版本 0.61。 I know that it can be a problem with AndroidX, and downgrade to RN 0.59 can help, but I think, that it's not a good idea.我知道这可能是 AndroidX 的问题,降级到 RN 0.59 会有所帮助,但我认为这不是一个好主意。

How can I fix this this problem?我该如何解决这个问题?

you have to replace your .\gradlew assembleRelease by ./gradlew assembleRelease你必须用./gradlew assembleRelease替换你的.\gradlew assembleRelease assembleRelease

The problem was solved.问题解决了。 npx jetify helped. npx jetify帮助。

暂无
暂无

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

相关问题 React Native Android:./gradlew assemble发布中断 - React Native Android: ./gradlew assembleRelease breaks with haul [react-native] gradlew assembleRelease --debug构建成功但gradlew assembleRelease构建失败 - [react-native]gradlew assembleRelease --debug build successful but gradlew assembleRelease build failed 使用'gradlew assembleRelease'反应本机Android构建失败 - React native Android build failing using 'gradlew assembleRelease' gradlew assembleRelease 它在 react-native 中给出以下错误 - gradlew assembleRelease it gives the following error in react-native 添加 React-Native-Camera 和 React-Native-Push-Notification 后无法构建 React Native - Can't build React Native after add React-Native-Camera and React-Native-Push-Notification ./gradlew assembleRelease构建React Native Web View而不是我的项目 - ./gradlew assembleRelease building React Native Web View instead of my project React Native Android-Gradlew assembleRelease命令无法生成APK输出 - React Native Android - gradlew assembleRelease command unable to generate apk output React Native./gradlew bundleRelease 或 assembleRelease 命令无限加载 - React Native ./gradlew bundleRelease or assembleRelease command loads infinitely 无法在 gradlew assembleRelease 上发布 react-native apk - Faild to release react-native apk on gradlew assembleRelease 任务:react-native-camera:compileGeneralDebugJavaWithJavac FAILED - Task :react-native-camera:compileGeneralDebugJavaWithJavac FAILED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM