After renaming the package name in android studio Startup error, runtime error

I have one project in android studio,

I first exported a project from eclipse to android studio. After that I changed my package name toAndroidMenifest.xml,

rename directories from Android Studio,

Changes the package name in all my class files

,

file position also changed R.java

And the gen

folder like old was com.oldpath.path1

before com.newpath.path2

.

Also reflect this in R.java file and BuildConfig.java file.

Now we get the error as it should.

    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.oldpath.path1/com.newpath.path2.main.SplashScreen }
Error type 3
Error: Activity class {com.oldpath.path1/com.newpath.path2.main.SplashScreen} does not exist.

      

Please help me, I am stuck with my project ..

+3


source to share


3 answers


Your best bet is to rename packages to right click on the package name -> refactor -> rename. So android studio will automatically rename whatever needs to be renamed.



+3


source


With Android Studio 3.0.1, it is not enough to simply refactor your package name with a tool Refactor -> Rename...

. First, as noted, this is missing several references throughout your project, including in your manifest file. Second, this skips the generated files and Android Studio cache (resulting in an OP identified error).

For those who stumbled upon this, if you haven't renamed your package yet, follow these steps: Android Service Pack for Android

Otherwise, if you have already tried and failed the error, the following steps will save your project:



Solution in Android Studio

  • Use Ctrl+Shift+F

    to find and replace any references to the old package name that were overlooked by the refactoring tool.
  • Correct any remaining bugs in your code, then clean and rebuild your application using Build -> Clean Project

    . This will restore your R file, fix the last related build error, but give you the startup error noted by the OP. Unfortunately, if you still have build errors, you are not quite facing the same problem as the OP ...
  • Prepare to restart the IDE (save your work and close all running emulators).
  • In Android Studio select File -> Invalidate Caches / Restart...

What is it! Android Studio will sync your Gradle file on restart and from now on it will reference your new package name when your application starts.

+1


source


You need to clean up the project after renaming packages as for some reason it doesn't rebuild it after renaming. Select Build -> Clean Project

and then start it again. It should be good.

0


source







All Articles