How to change package name of an Android Application

后端 未结 18 1152
攒了一身酷
攒了一身酷 2020-11-28 02:07

My keystore is corrupt, therefore the Android Market is requiring me to rename the app and resubmit it. However, whenever I go to edit the package names in Manifest and thro

相关标签:
18条回答
  • 2020-11-28 02:17

    There is a way to change the package name easily in Eclipse. Right click on your project, scroll down to Android Tools, and then click on Rename Application Package.

    0 讨论(0)
  • 2020-11-28 02:18
    1. Right Click on Project >Android Tools >Rename Application Package

    2. Go to src and right click on your main package >Refactor >Rename

    3. Go to manifest file and change your package name .

    0 讨论(0)
  • 2020-11-28 02:19

    The fastest way to do that in Android Studio 1.3:

    1. Change the package name in the manifest
    2. Go to Module Settings[F4]-> Flavors, into Application Id write the same name.
    3. Create new package with that name: [right-click-> new-> package]
    4. Select all java files of your project and then proceed [Right-click-> Refactor-> Move-> {Select package}-> Refactor]

    P.S. If you will not follow this order you can end up changing all the java files one by one with new imports and a bunch of compile time errors, so the order is very important.

    0 讨论(0)
  • 2020-11-28 02:19

    There is also another solution for users without Eclipse, simply change the package attribute in <manifest> tag in AndroidManifest.xml, by replacing the the old package name used with a new one. Note: You have to adjust the all the related import statements and related folders manually in your project than, too.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="new.package.name"
        .....
    </manifest>
    
    0 讨论(0)
  • 2020-11-28 02:20

    If you're using Eclipse, you could try these instructions from Android's developer site. They're specifically for the GestureBuilder sample but should apply to any application as far as I can tell:

    [H]ere's how you could do this in Eclipse:

    1. Right-click on the package name (src/com.android.gesture.builder).
    2. Select Refactor > Rename and change the name, for example to com.android.gestureNEW.builder.
    3. Open the manifest file. Inside the <manifest> tag, change the package name to com.android.gestureNEW.builder.
    4. Open each of the two Activity files and do Ctrl-Shift-O to add missing import packages, then save each file. Run the GestureBuilder application on the emulator.

    Also, be sure you remembered to rename the package itself along with the references to it in the files. In Eclipse you can see the name of the package in the file explorer window/tree view on the left hand side. In my experience, Eclipse can sometimes be a little finnicky and unreliable with this (leaving behind stray references to the old package name, for example).

    0 讨论(0)
  • 2020-11-28 02:21

    In Android Studio 1.2.2 Say if you want to change com.example.myapp to org.mydomain.mynewapp You can follow the steps in each of the directories as displayed in the below screen shot. It will give you the preview option so that you can preview before making any changes.

    Go to Refactor -> Rename and give your new name. You have to do it for each of the folders, say for com, example and myapp. It will automatically update the imports so that you don't have to worry about it.

    Also update the file build.gradle which is not updated automatically.

    defaultConfig {
            applicationId "org.mydomain.mynewapp" //update the new package name here
            minSdkVersion 15
            targetSdkVersion 22
            versionCode 1
            versionName "1.0"
        }
    

    After that it will ask for sync do it. Then everything will be fine. I'm able to upload my APK to google store after this. Make sure you have signed your app to upload it to the store.

    0 讨论(0)
提交回复
热议问题