Codepush React Native Android staging- Task installReleaseStagingDebug not found in root project
Asked Answered
G

2

12

I'm trying to configure my RN android project according to this section of the react-native-code-push docs

My build.gradle file has this configuration:

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

but when i run: react-native run-android --variant releaseStaging

I get the error: Task 'installReleaseStagingDebug' not found in root project 'MyAppName'.

Also tried running react-native run-android --configuration releaseStaging

Which gave me a slightly better error:

Task 'installReleaseStaging' not found in root project 'MyAppName'. Some candidates are: 'uninstallReleaseStaging'.

Any idea what i'm missing?
Thanks!
Uri

Gob answered 15/2, 2017 at 6:44 Comment(0)
L
24

You have to add signingConfig to the releaseStaging.

    releaseStaging {
        signingConfig signingConfigs.release
        buildConfigField "String", "CODEPUSH_KEY", CODEPUSH_KEY_STAGING
    }

Then you can install it to your device. I have react-native version 0.38 so I installed it with react-native run-android --variant=releaseStaging , but this might be different for other react-native versions. If you have a newer version of react-native, you can do react-native run-android --configuration=releaseStaging instead.

Lillis answered 17/2, 2017 at 2:15 Comment(0)
G
-2

The Android Gradle plugin allows you to define custom config settings for each "build type" (e.g. debug, release)

To set this up, Modify android/app/build.gradle in standard React Native projects

android {
...
buildTypes {
    debug {
        ...
        // Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
        buildConfigField "String", "CODEPUSH_KEY", '""'
        ...
    }

    releaseStaging {
        ...
        buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_STAGING_KEY>"'
        signingConfig signingConfigs.release
        ... 
    }

    release {
        ...
        buildConfigField "String", "CODEPUSH_KEY", '"<INSERT_PRODUCTION_KEY>"'
        signingConfig signingConfigs.release
        ...
    }
}
...

}

Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.

buildConfigField "String", "CODEPUSH_KEY", '""'

For latest react-native; you can build with

`react-native run-android --variant releaseStaging`
Glucinum answered 6/6, 2017 at 9:8 Comment(1)
This does not answer the question and seems to be mostly just copied from the CodePush docs.Photoplay

© 2022 - 2024 — McMap. All rights reserved.