3

I recently made a new app with just a minimal stub MainActivity. When I run the app using Android Studio and gradle project the app fails with the following message:

Uploading file
    local path: C:\Users\fnajmi\myapp-android\app\build\apk\app-debug-unaligned.apk
    remote path: /data/local/tmp/com.myapp.app
Installing com.myapp.app
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myapp.app"
pkg: /data/local/tmp/com.myapp.app
Success


Launching application: com.myapp/com.myapp.app.HomeActivity.
DEVICE SHELL COMMAND: am start -n "com.myapp.app/com.myapp.app.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.myapp.app/com.myapp.app.MainActivity }
Error type 3
Error: Activity class {com.myapp.app/commyapp.app.MainActivity} does not exist.

I have checked my entire project folder tree but I cannot find the word "myapp" anywhere. This was a package name I had used in the past but changed later. So where is this coming from I wonder?

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54

3 Answers3

10

The problem was found to be in some file in the ~/.gradle/cache tree. Removing this tree and rebuilding fixed the problem.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
  • @Shlublu, no, Farrukh should *remove* the question and answer, as it's no longer reproducible. – 323go May 21 '14 at 14:01
  • 3
    Actually, you can reproduce this if you change your entire project's package name manually and try to run it again. Clearing gradle's cache didn't work for me. What did work was adding the new package name to the defaultConfig configuration in the build.gradle file, as suggested here: http://stackoverflow.com/a/29862639/951722 – Henrique May 23 '15 at 14:20
0

This is duplication of answer but having gone round the houses the answer for me was edit the defaultConfig configuration in the build.gradle file as above. But this might help. When i was duplicating a project I found the refactoring did not locate this one and change it. Android Studio 2.2.2. So check it manually.

uberphoebe
  • 81
  • 2
  • 8
0

In my Android Studio Flamingo | 2022.2.1 it works after restarted with invalidate caches option.

  1. Click on File in toolbar and select Invalidate Caches...

Invalidate caches in file menu

  1. Select first option Clear file system cache and Local History in popup dialog and then click on Invalidate and Restart.

Select Invalidate and restart option in popup

Nitin Patel
  • 1,605
  • 13
  • 31