Safely remove an Android Activity

Just do it in a two steps in Android Studio.

  1. Delete the Activity's Java file: YourActivity.java
  2. Select app from the Project-Browser in Left Panel. Click Refactor from menu, click Remove Unused Resources.

You are done.


I found my answer. To remove an activity, let the name of the activity is activity:

  1. Remove the activity.java file from src folder (java/your.package.name folder for AndroidStudio)
  2. Remove the activity.xml file from layouts folder (layout folder for AndroidStudio)
  3. Remove the activity.xml file from res/menu folder (this is an optional folder)
  4. Remove the <activity></activity> block of the activity from the manifest file
  5. If the <activity> block in the manifest file has a reference (usually in android:label tag) remove the referenced value (usually from values/strings.xml).

According to answers from @ojonugwa ochalifu and @Md Tarik Mahmud you should also right click on app folder then Refractor -> Remove Unused Resources