Android Studio Rename Package
How do you rename packages in new IDE Android Studio, based on intelijj ?
Is there any automatic refactoring included?
I want to make bulk refactoring but I don't know how. I worked 2 years with eclipse and in eclipse it's one click operation.
In Android Studio, you can do this:
 For example, if you want to change com.example.app to my.awesome.game , then:  
In your Project pane , click on the little gear icon ( )
 Uncheck / De-select the Compact Empty Middle Packages option  

Your package directory will now be broken up in individual directories
Individually select each directory you want to rename, and:
Refactor  Rename  Rename Package instead of Rename Directory  com in Android Studio, it might give a warning.  In such case, select Rename All  
build.gradle - Usually app or mobile ).  Update the applicationId to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:  
 You may need to change the package= attribute in your manifest.  
Clean and Rebuild.
Done! Anyways, Android Studio needs to make this process a little simpler.
Another good method is: First create a new package with the desired name by right clicking on the java folder -> new -> package.
Then, select and drag all your classes to the new package. AndroidStudio will refactor the package name everywhere.
Finally, delete the old package.
Done.
One more thing very important
You have to Change manually Android Manifest and gradle file to the new package if you use this method.
Changing the application ID (which is now independent of the package name) can be done very easily in one step. You don't have to touch AndroidManifest. Instead do the following:
Note this will not change the package name. The decoupling of Package Name and Application ID is explained here: http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename
链接地址: http://www.djcxy.com/p/25490.html下一篇: Android Studio重命名包
