Cli: [Feature request] Change default name of released APK

Created on 22 Feb 2020  路  6Comments  路  Source: react-native-community/cli

Describe the Feature

I want to ask to create a line in android\gradle.properties when the project is initiated:

APP_NAME=xxx

Possible Implementations

It can be added when the project is created via react-native init xxx.

Related Issues

I want to create a PR in main repo to rename the release APK by adding this line to android\app\build.gradle:

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        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
        }

        output.outputFileName = "${APP_NAME}_v${defaultConfig.versionName}.apk"  // HERE
    }
}

And as it can be seen, i used a ${APP_NAME} which comes from android\gradle.properties

cc: @thymikee

feature request

All 6 comments

This would be quite a breaking change. We'd need to consult this with all major CD platforms and communicate this clearly. Personally I don't think it's necessary for a regular user and it's pretty easy to do in user space. I think I'd be more willing to document this as a part of run-android command, if one wants to adjust their bundle name.

This would be quite a breaking change. We'd need to consult this with all major CD platforms and communicate this clearly. Personally I don't think it's necessary for a regular user and it's pretty easy to do in user space. I think I'd be more willing to document this as a part of run-android command, if one wants to adjust their bundle name.

So, would you please direct me to make a PR to add this option to run-android, maybe something like run-android --name=MyAwesomeApp_v1.apk.

How should I start?

We should discuss it first. It's easy to add new APIs, but harder to remove them later. Please be patient and try to get as much feedback as possible.
cc @dulmandakh @Krizzu

Sorry to say, but I see no value in adding this to CLI.

Personally I don't think it's necessary for a regular user and it's pretty easy to do in user space

I agree. It's one-liner to add in the gradle script. Or you can add an extra step in CI, after building the apk file.

I agree with @Krizzu

So, I guess I should close this :grin:
Thanks for your feedback

Was this page helpful?
0 / 5 - 0 ratings