[java] How to change package name of an Android Application

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. enter image description here

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.