Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio fails to Build after package name refactor

I forked one of my old projects, so I refactored the package name in the Android manifest XML. The actual package name and all the references in JAVA are renamed properly. However, when I run I get the following error message:

Error type 3
Error: Activity class
{my.old.package/my.new.package.gui.activities.LightSettingsActivity} 
does not exist.

Apparently, the old package name is somewhere in configuration files where it does not belong I think.

Does someone know how to fix this?

like image 796
hasdrubal Avatar asked Apr 07 '15 13:04

hasdrubal


People also ask

How to enable build variant in Android Studio?

By default, Android Studio builds the debug version of your app, which is intended for use only during development, when you click Run. To change the build variant Android Studio uses, select Build > Select Build Variant in the menu bar.

Can we change package name in Android Studio?

Step by Step Implementation Step 2: Now click on the setting gear icon and deselect Compact Middle Packages. Step 3: Now the packages folder is broken into parts as shown in the below image. Step 4: Now right-click on the first package name (com) and Refactor > Rename.

How do you refactor on Android?

From the context menu, choose Refactor. From the submenu, choose Rename (or use the shortcut Shift + F6). Now, you can rename your method or member in place and apply the changes by hitting the Enter button. Android Studio provides you with some suggestions that you can accept or you can type the name you want.


1 Answers

I have had a similar issue. If you go to Build -> Clean Project, everything should work for you.

To quote a comment on my question:

It's not a bug. The Build Tool doesn't recognize the package name change and reuses the cache. "Clean Project" forces to rebuild all the classes

like image 200
AdamMc331 Avatar answered Sep 21 '22 06:09

AdamMc331