I’ve started adding product flavours to a react native android app as described here. But running the start script react-native run-android --mode=developmentdebug --appId .dev
hangs indefinitely on :app:createBundleDevelopmentDebugJsAndAssets
task.
Before adding the productFlavors to the build.gradle the app would start with react-native run-android"
.
Looking at other apps that setup product flavours, I don’t see anything different in my build.gradle config.
Any ideas what could be going wrong here with the createBundleDevelopmentDebugJsAndAssets
task?
Logs (The task just hangs at 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
This is a summarised version of the app/build.gradle for reference:
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)
So I needed to first build the initial app apks using Android Studio. I guess when I changed the package name to com.bvapps.chillmode
in manifest from what it was originally (com.myapp)react-native could no longer find the apk file.
Once I did this the app runs again with react-native run-android --mode=devDebug
.