Well, beforehand, I just wanted to tell you that the R
class is always created after Build. So if you changed the package for your project, remember to give clean project
and then build project
. Okay, now let's change the package for your project.
Change package in app / build.gradle
defaultConfig {
applicationId "co.mypack.myoldpack"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "R15.0c"
}
Change line applicationId to your new package
defaultConfig {
applicationId "co.mypack.mynewpack"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "R15.0c"
}
Change package in AndroidManifest.xml
package="co.mypack.myoldpack"
After changing the above line to package="co.mypack.mynewpack"
, you will have to create a new package in main/java/.
and then pass all your classes (copy and paste) to the new package and, finally, delete your package ancient.