Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Support for Variable Package names for ease in Testing #21

Open
codVenturer opened this issue May 16, 2024 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@codVenturer
Copy link
Contributor

Description

The mobile application has an identifier called package name (applicationId). When mobile app installed for internal testing and we want to switch to the production app, the app is updated and testing app is not longer on device and vice versa. This happens due to having the same package name for testing and production. This causes hindering in testing the app on mobile by having to multiple times switch between these apps and also causes confusion.
Hence to tackle this issue we would like to have variable package names for testing and production, so that multiple apps are on the device and have the ability to test simultaneously.

Implementation Steps/ Context

  • The applicationId can be found in the file /android/app/build.gradile, which looks something like this
android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.jalantechnologies.boilerplate"
    defaultConfig {
        applicationId "com.jalantechnologies.boilerplate"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1513956
        versionName "1.0"
    }
}
  • There are build flavours we can use to have different applicationId, details can be found here. this works for our purpose and can be implemented with ease.
  • If we want to have the variable applicationId for each build it is a bit tricky but we should be able to leverage GitHub actions set the applicationId prefix as a hash of the PR (this is being done for mere preview environments). Now how we can set that is another issue. The idea is to create a new file inside the android folder called local.properties which is like and environment file.
  • local.properties can have the variable names with values
BUILD_HASH=******

and this hash can be used in the build.gradle file by importing the file content

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def buildHash = properties.getProperty('BUILD_HASH')

The buildHash can be used in the flavours for prefix and that should work for our purpose.

@codVenturer codVenturer changed the title Feature: Add Support for Variable Package names for ease in Testing Feature Request: Add Support for Variable Package names for ease in Testing May 16, 2024
@bbbneo333 bbbneo333 changed the title Feature Request: Add Support for Variable Package names for ease in Testing feat: Add Support for Variable Package names for ease in Testing Jul 17, 2024
@bbbneo333 bbbneo333 added the enhancement New feature or request label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants