添加产品风格会导致构建挂在 :app:createBundleDevelopmentDebugJsAndAssets 任务上

问题描述 投票:0回答:1

我已经开始向 React Native Android 应用程序添加产品风味,如 此处所述。但是运行启动脚本

react-native run-android --mode=developmentdebug --appId .dev
会无限期地挂在
:app:createBundleDevelopmentDebugJsAndAssets
任务上。

在将 ProductFlavors 添加到 build.gradle 之前,应用程序将以

react-native run-android"
开头。

查看其他设置产品风味的应用程序,我在 build.gradle 配置中没有看到任何不同。

您知道

createBundleDevelopmentDebugJsAndAssets
任务可能出什么问题吗?

日志(任务仅挂在 11%)

Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Configure project :app
Reading env from: .env.debug
WARNING: DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.

> Configure project :react-native-reanimated
Android gradle plugin: 8.1.1
Gradle: 8.3

> Task :app:createBundleDevelopmentDebugJsAndAssets
debug Reading Metro config from /Users/brianvarley/Projects/ChillMode/metro.config.js
warning: the transform cache was reset.
                Welcome to Metro v0.80.6
              Fast - Scalable - Integrated


<=------------> 11% EXECUTING [9m 12s]
> IDLE
> :app:createBundleDevelopmentDebugJsAndAssets

这是app/build.gradle的总结版本,供参考:

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

project.ext.envConfigFiles = [
   productionrelease: ".env.prod",
   developmentdebug: ".env.debug",
]

project.ext.react = [
    inputExcludes: ["ios/**", "__tests__/**", "bundle_out/**"]
];
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

...

android {

    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "8g"
    }

    ndkVersion rootProject.ext.ndkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace "com.bvapps.chillmode"
    flavorDimensions "default"
    defaultConfig {
        applicationId "com.bvapps.chillmode"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.env.get('RELEASE_STORE_FILE')) {
                storeFile file(project.env.get('RELEASE_STORE_FILE'))
                storePassword project.env.get('RELEASE_STORE_PASSWORD')
                keyAlias project.env.get('RELEASE_KEY_ALIAS')
                keyPassword project.env.get('RELEASE_KEY_PASSWORD')
            }
        }
    }
    productFlavors {
        production {
            dimension "default"
            applicationIdSuffix ".prod"
        }
        development {
            dimension "default"
            applicationIdSuffix ".dev"
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        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"
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation("com.facebook.react:flipper-integration")

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

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


android react-native build.gradle
1个回答
0
投票

虽然官方的 react native setup docs 没有提到这一点。对我来说解决这个问题的方法是安装缺少的 - Android SDK 命令行工具。

android studio sdk

© www.soinside.com 2019 - 2024. All rights reserved.