Title

Thursday, 5 February 2015

Package renaming in eclipse android project


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

Thanks, Dheepak

Answer

This is a bug in eclipse android tools http://code.google.com/p/android/issues/detail?id=2824

To Fix -> Right click on the project go to Android tools -> Rename application package..

And also check AndroidManifest.xml if it updated correctly, in my case it didn't, that should solve this problem

Answer2

To change the app name when in Android, go to res/values/strings.xml and change app_name to what you want.

Answer3

None of these worked for me, they all introduced errors.

The following worked for me:

  • Right click the project and select Android Tools >> Rename Application Package.
  • Enter the new Package name
  • Accept all the automatic changes it wants to make
  • Say yes to update the launch configuration
Answer4

One Extremely Important NOTICE:

NEVER use direct package names as in something similar to passing a string value containing the package name. Use the method getPackageName(). this will make the renaming dynamic. Do whatever to reach the method getPackageName().

in Eclipse Juno, the Correct Way of renaming is:

  1. go and edit the manifest.
  2. remove every old package name in the manifest.
  3. put instead of the old package name, the new package name in every location inside the manifest. You might have classes(Activities that is) that need direct package name references.
  4. save the manifest.
  5. Then Right click the package name inside the project.
  6. Select "Refactor".
  7. Select "Rename".
  8. Type the new package name.
  9. select "update references".
  10. press OK and your done and watch out also what should be done to replace the new name.
  11. DON'T forget to update also the layout xml files with the new package name. you might have a custom View. look for them.
Answer5

Just right click on the Project name and select Android tools and click Rename Application Package name and rename it.Its only for Android Projects..

Answer6

Press F2 then Rename it(Or Right click on the Project and select Rename). It changes wherever that package declared in your project its automatically renamed allover.

Answer7

Goto Src folder of your android project, 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 : Goto AndroidManifest.xml and change package="OldName.android.widget" to package="newName.android.widget"

No comments:

Post a Comment