You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue is same as reported earlier in #921, but marked PR did not fix the issue.
npx react-native run-android fails with Failed to install the app on the device. Error: Could not find the correct install APK file. when using flavors.
productFlavors {
pro {
dimension = 'version'
applicationId = 'com.ezmonic'
applicationIdSuffix = 'pro'
resValue "string", "app_name", "Ezmonic"
}
free {
dimension = 'version'
applicationId = 'com.ezmonic'
resValue "string", "app_name", "Ezmonic Free"
}
}
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.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
$ yarn react-native run-android --deviceId=emulator-5554 --mode=freeDebug --appIdSuffix=free
info A dev server is already running for this project on port 8081.
info Building the app...
> Configure project :app
Reading env from: .env.development
Reading from .env
...
> Task :app:installFreeDebug
Installing APK 'app-free-debug.apk' on 'Pixel_7_Pro_API_34(AVD) - 14'for :app:free-debug
Installed on 1 device.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 13s
465 actionable tasks: 18 executed, 447 up-to-date
info Connecting to the development server...
8081
error Failed to install the app on the device.
Error: Could not find the correct install APK file.
Reproducible Demo
Error is coming from the following lines in
Issue lies in tryInstallAppOnDevice() function. Use case is when build is triggered using non-interactive manner, via Terminal command, yarn react-native run-android --deviceId=emulator-5554 --mode=freeDebug --appIdSuffix=free. As per code, split is done only for selectedTask, which is populated in case of interactive mode, but not for args.mode, which is one of the input during manual build.
functiontryInstallAppOnDevice(args: Flags,adbPath: string,device: string,androidProject: AndroidProject,selectedTask?: string,){try{// "app" is usually the default value for Android apps with only 1 appconst{appName, sourceDir}=androidProject;constdefaultVariant=(args.mode||'debug').toLowerCase();// handle if selected task from interactive mode includes build flavour as well, eg. installProductionDebug should create ['production','debug'] arrayconstvariantFromSelectedTask=selectedTask?.replace('install','').split(/(?=[A-Z])/);// create path to output file, eg. `production/debug`constvariantPath=variantFromSelectedTask?.join('/')?.toLowerCase()??defaultVariant;// create output file name, eg. `production-debug`constvariantAppName=variantFromSelectedTask?.join('-')?.toLowerCase()??defaultVariant;letpathToApk;if(!args.binaryPath){constbuildDirectory=`${sourceDir}/${appName}/build/outputs/apk/${variantPath}`;constapkFile=getInstallApkName(appName,adbPath,variantAppName,device,buildDirectory,);pathToApk=`${buildDirectory}/${apkFile}`;}else{pathToApk=args.binaryPath;}constinstallArgs=['-s',device,'install','-r','-d'];if(args.user!==undefined){installArgs.push('--user',`${args.user}`);}constadbArgs=[...installArgs,pathToApk];logger.info(`Installing the app on the device "${device}"...`);logger.debug(`Running command "cd android && adb ${adbArgs.join(' ')}"`);execa.sync(adbPath,adbArgs,{stdio: 'inherit'});}catch(error){thrownewCLIError('Failed to install the app on the device.',errorasany,);}}
The text was updated successfully, but these errors were encountered:
Environment
Description
Issue is same as reported earlier in #921, but marked PR did not fix the issue.
npx react-native run-android
fails withFailed to install the app on the device. Error: Could not find the correct install APK file.
when using flavors.Reproducible Demo
Error is coming from the following lines in
Issue lies in
tryInstallAppOnDevice()
function. Use case is when build is triggered using non-interactive manner, via Terminal command,yarn react-native run-android --deviceId=emulator-5554 --mode=freeDebug --appIdSuffix=free
. As per code, split is done only forselectedTask
, which is populated in case of interactive mode, but not forargs.mode
, which is one of the input during manual build.The text was updated successfully, but these errors were encountered: