React-native-code-push: Running a Local Debug Build [Android]

Created on 21 Oct 2016  路  4Comments  路  Source: microsoft/react-native-code-push

I would like to be able to create a local debug build (loading the JS package from my machine), but with the current instructions I am only able to create a Staging and Production build that loads the JS bundle from CodePush. I think my confusion mostly lies in the fact that we have explicitly overrode the getJSBundleFile Method in MainApplication.java, and I can't seem to figure out how to conditionally override it based on the set buildType

  • react-native-code-push version: v1.15-beta
  • react-native version: 0.34.1
  • iOS/Android/Windows version: Android

Most helpful comment

@ninjz: from my build.gradle, maybe it helps:

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

        // HACK: Name it "stagingrelease" so react-native (via react.gradle) will build it as a release
        stagingrelease.initWith(buildTypes.release)
        stagingrelease {
            buildConfigField "String", "CODEPUSH_KEY", '"staging-keyz"'
        }
    }

This setup works well for me for now. a release-quality build with stagingreleasereading from code-push staging deployments. a debug that won't get anything from code-push. and a release with a code-push release key.

All 4 comments

Hi @ninjz, I believe that when running in debug mode, React Native will force your app to load from the packager, regardless of what you have instrumented in code. More information here: https://github.com/Microsoft/react-native-code-push/issues/153

Does this resolve the problem for you?

Hi @silhouettes I think that solves my issue, but now I am confused as to how to have a staging environment for my application. According to the instructions we are to put our staging environment configs in the debug buildType, but since that loads up the app from the packager then it technically is not getting my staging build either

@ninjz: from my build.gradle, maybe it helps:

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

        // HACK: Name it "stagingrelease" so react-native (via react.gradle) will build it as a release
        stagingrelease.initWith(buildTypes.release)
        stagingrelease {
            buildConfigField "String", "CODEPUSH_KEY", '"staging-keyz"'
        }
    }

This setup works well for me for now. a release-quality build with stagingreleasereading from code-push staging deployments. a debug that won't get anything from code-push. and a release with a code-push release key.

Ok that actually makes a lot of sense now. Thanks @ippa !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ACCTFORGH picture ACCTFORGH  路  3Comments

kevando picture kevando  路  4Comments

Fuhrmann picture Fuhrmann  路  3Comments

fanzhiri picture fanzhiri  路  3Comments

Adr1ann picture Adr1ann  路  3Comments