Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio gets package name wrong when running .apk

I changed my package name from com.mycompany.myapplication to com.mycompany.testapp.

Everything builds fine but when I try to run it on the emulator, I get:

The session was restarted Target device: NexusS [emulator-5554] Uploading file local path: /home/antony/AndroidStudioProjects/testappProject/testapp/build/apk/testapp-debug-unaligned.apk remote path: /data/local/tmp/com.mycompany.myapplication Installing com.mycompany.myapplication DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.mycompany.myapplication" pkg: /data/local/tmp/com.mycompany.myapplication Success

Launching application: com.mycompany.myapplication/com.mycompany.testapp.MainActivity. DEVICE SHELL COMMAND: am start -D -n "com.mycompany.myapplication/com.mycompany.testapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mycompany.myapplication/com.mycompany.testapp.MainActivity } Error type 3 Error: Activity class {com.mycompany.myapplication/com.mycompany.testapp.MainActivity} does not exist.

Note the remote path ^^^ is wrong.

If I go to the emulator, I can start the app from the menu, it's just that I get this error when i try to run the app from Android Studio.

I also see in logcat, on the top-right, the drop-down offers me "No Filters" or "app:com.mycompany.myapplication". So I can't even debug properly.

Where are these references to com.mycompany.myapplication coming from, and how can I fix this?

like image 706
antgel Avatar asked Mar 03 '14 19:03

antgel


People also ask

Can we change package name of APK?

I would recommend unpacking the apk with apktool, and then edit the apktool. yml, setting renameManifestPackage to the new package name. Then when you rebuild the apk with apktool, it should use aapt's --rename-manifest-package functionality to change the package name.

Does package name matter Android studio?

No it wont have any change.

What is package name in APK?

The APK Package Name is the directory of the app on the Android operating system, as well as the address of the app on the Google Play Store. Therefore, the APK Package Name must be unique (multiple apps with the same APK Package Name cannot be published).


2 Answers

I tried to restart Android Studio but the problem still existed.

Then the solution works with me.

  1. Remove the directory ~/.gradle/caches/. It's OK to do this while Android Studio is opened. (Refer pm installing wrong package name)
  2. Press "Sync project with Gradle files" icon on Android Studio
  3. Run the project and the remote path will be correct.
like image 77
Jack Fan Avatar answered Oct 21 '22 10:10

Jack Fan


Here is how I solved it. Very simple.

Click the 'Sync Project with Gradle Files' button at the top of the window.

'Sync Project with Gradle Files' button screenshot

Look for this button if you're using newer version of Android Studio:

'Sync Project with Gradle Files' button in newer AS screenshiot

'Sync Project with Gradle Files' button in latest AS screenshiot

like image 32
Jonas Borggren Avatar answered Oct 21 '22 11:10

Jonas Borggren