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
What you expected to happen?
App updates on new codepush release
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.
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.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-parametertargetBinaryVersion 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
MainApplication.java file
I see a related issue below
https://github.com/Microsoft/code-push/issues/560
Most helpful comment
Hi
I have been successfully using below two commands for Dynamic deployment via code-push CLI
Now, what I want is to run dynamic deployment for a particular product flavour (in my case it is
playstoreflavour). Basically i want combination of dynamic deployment and flavour build via code-push CLICan anyone help me with the exact commands for the above case ? How can i specify flavour in the
code-push release-reactcommandandroid/app/build.gradle file
The below file contains
playstoreproduct flavourbuild.gradle.log
MainApplication.java file
MainApplication.java.log
I see a related issue below
https://github.com/Microsoft/code-push/issues/560