Refactoring package name breaks entire app

I am trying to refactor my package using Eclipse

org.sheehan.activity

to

  • Center elemets of HorizontalScrollView when not enough to make it scroll
  • Samsung Galaxy/Holoeverywhere - Resource is not a ColorStateList (color or path)
  • How to include a Java project in an Android project?
  • Android actionbar not visible
  • Install launcher icon in home screen once
  • Places Autocomplete Status Code 9001
  • org.sheehan.stocks.activity
    

    For some reason my project just blows up when I do this and R doesn’t get regenerated. How can I refactor properly?

    UPDATE:
    I updated my Android Manifest to reflect the change. R still doesn’t get regenerated. Even after a clean. The compiler is complaining about org.sheehan.activity.R

    Related posts:

    Controlling view visibility from a resources
    Can Activity.getIntent() ever return null?
    Bitmap from TextView (getDrawingCache) always null
    Error using eclipse for Android - No resource found that matches the given name
    Firebase dynamic link not opening the app
    libgdx doesn't render fonts properly after resume
  • Android - Use of view.setX() and setY in api 8
  • Android Support Library Direct Link for Downloading
  • Last Harka is showing before the first character of the line in Arabic Reshaper on Android
  • Android Camera onPreviewFrame frame rate not consistent
  • How to set shared checkable behavior across all groups in NavigationView?
  • rawQuery(query, selectionArgs)
  • 7 Solutions collect form web for “Refactoring package name breaks entire app”

    I resolved by:

    Android Tools > Rename Package Application
    

    If you renamed properly, all your references across your project should have gotten updated. After doing this, clean your project by going to Project > Clean. This should fix it.

    Fixing missing reference to R in eclipse:

    1. Refactor -> Rename`

    2. Build -> Clean

    3. Android Tools -> Fix Project Properties

    select the base package of your project in the eclipse package explorer, press F2 (Rename), in the rename dialog: SELECT ALL the checkboxes.:
    enter image description here

    That should do it

    The package name doesn’t update in the XML files. Specifically your manifest which needs to know the base package.

    For more advanced imports and refactors, literally closing the Eclipse IDE can refresh a cache that causes random errors like “End position lies outside document range” or the “what once worked now doesn’t hair puller outter errors.”

    Signs you should close Eclipse when trying to rename things are:

    1. When you import a project, do some refactoring (like trying to change the package name), then delete the project and try again, you will see immediate R.java errors when you didn’t before

    2. When you are importing projects that have manually generated R.java files that have custom imports like “com.ns.proj.R” and don’t see the name update in Preview

    3. The box that asks if you want to “Rename subpackages” is checked unexpectedly

    4. the code in the “Preview>>” looks as if it’s been complied before instead of black and white code with the proper names replaced

    5. you get XML errors in the manifest activity name like this

    android:name=”com.ns.proj.CustomCocom.ns.proj.CustomControlse=”@android:style/Theme.Light.NoTitleBar”

    when it should be

    android:name=”com.ns.proj.CustomControls”
    android:style=”Theme.Light.NoTitleBar”

    There are too many to name obviously, however this is as important as “keep your eye on the ball” in sports. Something that is so easy to forget, yet things like these apply to other software programs like Dreamweaver (e.g. when you use the Dreamweaver “Put” option instead of FTP dragging with FileZilla and you notice your domain isn’t updating your changes online). I called Adobe when I first started as a developer 8 years ago because I knew I wasn’t doing anything wrong. They said sometimes the generated files to perform the action get corrupted…in other words, IDE’s have bugs too!

    In general, close the IDE before you off yourself…it could save your life!

    Right click in your Project, go to

    Android Tools > Rename Package Application
    

    Sometimes if Project > Clean doesn´t work, so Delete /gen and /bin folders of your project.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.