How to change package name of Android Project in E

2019-01-03 01:49发布

I have an Android project created in Eclipse. I want to modify the package name and application of the project. How do I do that in Eclipse?

16条回答
叼着烟拽天下
2楼-- · 2019-01-03 02:36

Goto the Src folder of your Android project, and open the Java file.

Change the package OldName.android.widget to newName.android.widget.

It gives you an error like this

The declared package "newName.android.widget" does not match the expected package "OLDName.android.widget.

To fix this problem, select Move filename.Java to Newname.android.widget and delete the old package folder.

Next step: Go to AndroidManifest.xml and change package="OldName.android.widget" to package="newName.android.widget".

查看更多
SAY GOODBYE
3楼-- · 2019-01-03 02:40

Renaming an Application- The Complete Guide

**A) for changing Just the application name
   (App name which is displayed below icon)
    in the Manifest.xml file, in <application tag, 
    android:label="YourAppName"
    then do the same in All the <activity Tags        

  B) For changing EVERYTHING 
   (folder names, Package names, Refrences,app name, etc.)
  *1) Renaming package names in gen folder and manifest.xml
      Right Click on Your project
      Android tools- Rename Application Package

  *2) Renaming package names in src folder 
      Expand src folder, Click on package (Single click) 
      Press Alt+Shift+R
      Check Update references and Rename subpackages      
   3) Renaming the app's main Folder (Optional)
      click on the application's folder (Single click)
      then Press Alt+Shift+R 

   4) Renaming application name- Refer "A)"**
查看更多
时光不老,我们不散
4楼-- · 2019-01-03 02:43

I had big trouble with this too.

I renamed the project and the package via refactoring, but it rendered the app useless. I renamed it back to the original and used the Android tools to rename the package and this worked, but my package folder and classes had the old name.

I then refactored the package folder. Now the app wouldn't run. My manifest was a mess. It doubled up my launcher name for example, com.ronguilmet.app/com.ronguilmet.com.class. I fixed that, and I had to manually edit all activities.

查看更多
等我变得足够好
5楼-- · 2019-01-03 02:45

None of this worked for me until I combined the two answers mentioned in this post.

Step 1: Right click on the project -> Select Android Tools -> Rename application Package. (This will change all the files in the gen folder and in AndroidManifest but will not change the package name in the src folder so I followed Step 2)

Step 2: Inside src folder Right Click your package name -> Refactor -> Rename -> Enter the new name that you entered in Step 1.

Just to make sure Check AndroidManifest if there is still the old package name and replace with the new one (in my case inside the "uses-permission" tag).

Then close the Eclipse and Reopen it. Uninstall the app from your device and install it again and everything should be working fine.

Hope this helps and saves your time.

查看更多
登录 后发表回答