Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In multi deployment builds, run-android launches the wrong version of the app #611

Closed
chetstone opened this issue Nov 17, 2016 · 8 comments

Comments

@chetstone
Copy link

chetstone commented Nov 17, 2016

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

  • react-native-code-push version: 1.14.6-beta
  • react-native version: 0.32.1
  • iOS/Android/Windows version: android Samsung Galaxy S5 SM-G900T - 6.0.1
  • Does this reproduce on a debug build or release build? debug build
  • Does this reproduce on a simulator, or only on a physical device? Both
  • Repro steps and/or stack trace:

I followed the instructions in the README for installing both debug and release builds simultaneously on the same device. It mostly works, but when I build the debug version with react-native run-android it installs the debug version on the device but launches the release version when the install is done. Not a serious problem but a minor annoyance to have to launch the debug version by hand. There must be a setting missing in the gradle files.

Sometimes, when the release version is already running, run-android will print the following message:

Starting: Intent { cmp=io.malamode/.MainActivity }
Warning: Activity not started, its current task has been brought to the front

(The more info the faster we will be able to address it!)

@matrosov-nikita
Copy link

Hi @chetstone

It is problem of react-native, which ignores applicationIdSuffix property from build.gradle file. There are two ways to resolve this problem - either run debug version manually (something that you already mentioned) or run the following script from your app directory:

cd android && ./gradlew installDebug && adb -s <DEVICE_ID> shell am start -n <PACKAGE_ID>.debug/<PACKAGE_ID>.MainActivity

cd android && gradlew.bat installDebug && adb -s <DEVICE_ID> shell am start -n <PACKAGE_ID>.debug/<PACKAGE_ID>.MainActivity

where PACKAGE_ID is you package identifier (something like com.mycompany.myapp) and DEVICE_ID is a device identifier as listed by adb devices

Based on this I'd suggest you to report this issue in react-native or use these workarounds.

@chetstone
Copy link
Author

@matrosov-nikita Thanks very much for the script. I'll give it a try.

This issue has been reported on Product Pains and there is a PR pending to fix it.

@vladimir-kotikov
Copy link

Cool, thanks for the links, @chetstone!

@nordfogel
Copy link

nordfogel commented Dec 27, 2017

@matrosov-nikita: thanks for your workaround which is still necessary even a year after your suggestion. this issue is still valid and its initial PR pointed out from @chetstone led to a corresponding PR which has been closed misleadingly without merge. At least it has gotten some attention since last week. Unfortunately it seems like a new issue needs to be filed..

a short addition
-d instead of -s <DEVICE_ID>
can be used if there is only one device connected via usb. e.g.
$ cd android && ./gradlew installAlphaRelease && adb -d shell am start -n <PACKAGE_ID>.alpha/<PACKAGE_ID>.MainActivity
while Alpha is a build flavour

@xanderberkein
Copy link

xanderberkein commented Apr 12, 2018

You can run your app with the appIdSuffix param

react-native run-android --appIdSuffix "debug"

You can find all the available params here: https://github.com/facebook/react-native/blob/master/local-cli/runAndroid/runAndroid.js#L301

Source: https://stackoverflow.com/a/48340408/5791025

@johanforssell
Copy link

I'm writing new versions of old apps, and thus I have inherited old app id's.

My code have the package com.common.package (in source files and AndroidManifest.xml).

My build.gradle contains

    buildTypes {
        debug {
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    flavorDimensions "appName"
    productFlavors {
        appAAA {
            dimension "appName"
            applicationId "com.AAA.app"
            versionCode 100
            versionName "3.0.0"
        }
        appBBB {
            dimension "appName"
            applicationId "com.BBB.app"
            versionCode 100
            versionName '3.0.0'
        }
    }

First the app can be installed with gradlew

cd android && ./gradlew installAppBBBDebug

The I can start it manually with

adb -s emulator-5554 shell am start -n com.BBB.app/com.common.package.MainActivity

This is a bloody hassle. I would rather not have to mess with it like this.

@rafaelmaeuer
Copy link

This is still an issue using android debug with launch.json in vscode. Is there no fix yet or planned?
As @matrosov-nikita mentioned, react-native is ignoring applicationIdSuffix property from build.gradle.

@lucianbc
Copy link

This is still an issue. The code in this PR seems to solve it, but in the meantime, I guess the CLI has been moved here and since it fails to find the correct package, I assume the new file has a bug.
My assumption is that the manifest file is not picked up correctly from the build folder in android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants