React-native-code-push: Android: app not updating when using build flavor with applicationIdSuffix

Created on 25 Oct 2017  Â·  10Comments  Â·  Source: microsoft/react-native-code-push

For my regular release and staging deployments everything works perfectly fine but not for my additional app flavors. I've already debugged the initialization of CodePush and can confirm that the proper deployment keys are passed to new CodePush for each flavor in MainApplication.java

Steps to Reproduce

  1. Setup an Android app with multiple build flavors
  2. Add a applicationIdSuffix to one of them
  3. Assign proper deployment keys to each flavor/buildType by iterating applicationVariants

Expected Behavior

What you expected to happen?
App updates on new codepush release

Actual Behavior

What actually happens?
App always just logs " Loading JS bundle from "assets://index.android.bundle"" but never fetches the new update as the default flavor does.

Environment

  • react-native-code-push version: 5.1.3-beta
  • react-native version: 0.47.2
  • iOS/Android/Windows version: 6.0 and others
  • Does this reproduce on a debug build or release build? release
  • Does this reproduce on a simulator, or only on a physical device? both
android waiting-for-clarification

Most helpful comment

Hi

I have been successfully using below two commands for Dynamic deployment via code-push CLI

1. code-push deployment add  <app_name> <deployment_name>
2. code-push release-react -m <app_name> android  -d <deployment_name>

Now, what I want is to run dynamic deployment for a particular product flavour (in my case it is playstore flavour). Basically i want combination of dynamic deployment and flavour build via code-push CLI

Can anyone help me with the exact commands for the above case ? How can i specify flavour in the code-push release-react command

android/app/build.gradle file

The below file contains playstore product flavour

build.gradle.log

MainApplication.java file

MainApplication.java.log

I see a related issue below
https://github.com/Microsoft/code-push/issues/560

All 10 comments

Hi @matthiasleitner, thanks for reaching us and sorry for the delayed response. Could you please share with us your build.gradle file and also provide the way you are initializing CodePush instance int the MainApplication.java file?

@sergey-akhalkov sure here is my configuration

    buildTypes {
        debug {
            buildConfigField "String", "CODEPUSH_KEY", '""'
            applicationIdSuffix ".debug"
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }

        releaseStaging {
            applicationIdSuffix ".staging"
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // 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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            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
            }
        }

        if (variant.getName() == "defaultFlavourRelease") {
            variant.buildConfigField "String", "CODEPUSH_KEY", "\"defaultRleaseKey\""
        } else if (variant.getName() == "defaultFlavourReleaseStaging") {
            variant.buildConfigField "String", "CODEPUSH_KEY", "\"defaultStagingKey\""
        } else if (variant.getName() == "flavour1Release") {
            variant.buildConfigField "String", "CODEPUSH_KEY", "\"flavourreleasekey\""
        } else if (variant.getName() == "flavour1ReleaseStaging") {
            variant.buildConfigField "String", "CODEPUSH_KEY", "\"flavourstagingkey\""
        }
    }

    productFlavors {
        defaultFlavour {
            applicationIdSuffix ""
            versionNameSuffix ""
            manifestPlaceholders = [
                appIcon: "@mipmap/ic_launcher",
                urlSchema: "defaultFlavour"
            ]
        }
        flavour1 {
            applicationIdSuffix ".flavour1"
            versionNameSuffix "-flavour1"
            manifestPlaceholders = [
                appIcon: "@mipmap/ic_launcher",
                urlSchema: "flavour1"
            ]
        }
    }

Init of CodePush In MainApplication.java

return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new CodePush(BuildConfig.CODEPUSH_KEY, getApplicationContext(), BuildConfig.DEBUG)

@matthiasleitner, great, thanks.
From the code you have provided I can see that you are using variant.buildConfigField "String", "CODEPUSH_KEY", "\"flavourreleasekey\"" approach to "patch" your BuildConfig, so could you please make sure if your BuildConfig.CODEPUSH_KEY has non-null/empty-sting value and it actually matches with the productFlavor you have selected for build (just add some kind of logging before initializing the CodePush)?

I’ve logged the value of BuildConfig.CODEPUSH_Key from MainApplication and
it has correct value for all flavours and build types
Sergey Akhalkov notifications@github.com schrieb am Fr. 27. Okt. 2017 um
14:06:

@matthiasleitner https://github.com/matthiasleitner, great, thanks.
From the code you have provided I can see that you are using variant.buildConfigField
"String", "CODEPUSH_KEY", ""flavourreleasekey"" approach to "patch"
your buildTypes, so could you please make sure if your
BuildConfig.CODEPUSH_KEY has non-null/empty-sting value and it actually
matches with the productFlavors you have selected for build?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/react-native-code-push/issues/1060#issuecomment-339953122,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB8hiNa6PFsj4ZMYU2gogC3k0-dUjZ3uks5swcctgaJpZM4QGF_j
.

@matthiasleitner, got it, I have a couple of questions then:

  1. what command you are using for build your apk?
  2. what version has your built app/apk, something like 1.0.0-flavour1? If so, please note that CodePush uses semver rules while working with versions: https://github.com/Microsoft/code-push/tree/master/cli#target-binary-version-parameter
  3. what command you are using for releasing updates for specific flavor, have you specified the targetBinaryVersion parameter to inform the CLI that it should use version 1.0.0-flavour1 (versionName + versionNameSuffix)?

Hey @matthiasleitner do you happen to have any updates about it?

@sergey-akhalkov Thanks for checking back, I currently suspect that the issue might occur because of my versionNameSuffix on the flavour, will try to test this today.

@sergey-akhalkov I just removed the versionNameSuffix from my flavor and it works now. I don't really need the suffix at the moment.

Thanks for your help!

_# ###SOLUTION

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

OUTPUT will be :
c:UserslengerDesktopwebrowser>react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
Scanning folders for symlinks in c:UserslengerDesktopwebrowsernode_modules (43ms)
Scanning folders for symlinks in c:UserslengerDesktopwebrowsernode_modules (38ms)
Loading dependency graph, done.
bundle: start
bundle: finish
bundle: Writing bundle output to: android/app/src/main/assets/index.android.bundle
bundle: Done writing bundle output

and after

Run react-native run-android again, you will find your modification work.

from https://lengerrong.blogspot.am/2018/01/react-native-run-android-do-not.html

Hi

I have been successfully using below two commands for Dynamic deployment via code-push CLI

1. code-push deployment add  <app_name> <deployment_name>
2. code-push release-react -m <app_name> android  -d <deployment_name>

Now, what I want is to run dynamic deployment for a particular product flavour (in my case it is playstore flavour). Basically i want combination of dynamic deployment and flavour build via code-push CLI

Can anyone help me with the exact commands for the above case ? How can i specify flavour in the code-push release-react command

android/app/build.gradle file

The below file contains playstore product flavour

build.gradle.log

MainApplication.java file

MainApplication.java.log

I see a related issue below
https://github.com/Microsoft/code-push/issues/560

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Phredward picture Phredward  Â·  3Comments

ACCTFORGH picture ACCTFORGH  Â·  3Comments

Adr1ann picture Adr1ann  Â·  3Comments

vira-khdr picture vira-khdr  Â·  3Comments

panarasi picture panarasi  Â·  4Comments