How to change Android App Name and ID of an existing application?

后端 未结 11 1574
刺人心
刺人心 2020-12-29 23:01

I have two Android projects in Eclipse. I copied the one project from the other, then changed the app name (in strings.xml) and the project name

11条回答
  •  执笔经年
    2020-12-29 23:42

    The most simple way I have found to accomplish this task is to utilize Product Flavor in .gradle

    productFlavors {
        MainApp {
            applicationId = "com.company.app"
        }
        NewAppFlavor {
            applicationId = "com.company.newapp"
        }
    }
    
    buildTypes {
        debug {
            buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" +  getDateAsMillis() + "L)"
            applicationIdSuffix ".debug"
        }
    }
    

    You then specify package name in AndroidManifest.xml as

    
    

    Upon release configuration, Android Studio (1.5.1 as of this writing) will ask which flavor to build.

    Debug configuration is a little less intuitive, you must hover the cursor over the bottom left corner of the screen, select "Build Variants" and select which flavor your debug configuration will deploy when you press the play button.

提交回复
热议问题