4

I'm using latest android studio, usb debugging enabled, phone recognized by AS and code sucesfully compiled and run on simulator, however when I actaully trying to run app, it's fails with this error:

$ adb shell am start -n "com.example.ph.myapplication/com.example.ph.myapplication.OnlyTetstBBBAct" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "com.example.ph.myapplication/com.example.ph.myapplication.OnlyTetstBBBAct" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.ph.myapplication/.OnlyTetstBBBAct }
Error type 3
Error: Activity class {com.example.ph.myapplication/com.example.ph.myapplication.OnlyTetstBBBAct} does not exist.

Error while Launching activity

At the same time I could see something like this in android monitor window (however I'm not sure is it 100% correlated):

01-12 17:50:19.111 18352-18352/? E/appproc: ERROR: could not find class 'com.android.commands.pm.Pm'
01-12 17:50:19.111 18352-18352/? A/art: art/runtime/thread.cc:1143] No pending exception expected: java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
01-12 17:50:19.111 18352-18352/? A/art: art/runtime/thread.cc:1143]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
01-12 17:50:19.111 18352-18352/? A/art: art/runtime/thread.cc:1143]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:511)
01-12 17:50:19.111 18352-18352/? A/art: art/runtime/thread.cc:1143]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:469)
01-12 17:50:19.111 18352-18352/? A/art: art/runtime/thread.cc:1143] 
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] Runtime aborting...
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] Aborting thread:
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] "main" prio=5 tid=1 Runnable
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   | group="" sCount=0 dsCount=0 obj=0x12c41100 self=0x55bed629b0
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   | sysTid=18352 nice=0 cgrp=default sched=0/0 handle=0x7fb6243e80
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   | state=R schedstat=( 347813798 1653280 115 ) utm=22 stm=12 core=1 HZ=100
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   | stack=0x7fddc23000-0x7fddc25000 stackSize=8MB
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   | held mutexes= "abort lock" "mutator lock"(shared held)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   native: #00 pc 000039a4  /system/lib64/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEmP8ucontext+28)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   native: #01 pc 0000001c  ???
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   (no managed stack frames)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] Pending exception java.lang.ClassNotFoundException thrown by 'unknown throw location'
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:511)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289]   at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:469)
01-12 17:50:19.231 18352-18352/? A/art: art/runtime/runtime.cc:289] Dumping all threads without appropriate locks held: thread list lock
...

This is a very annoying problem for me, I'm trying to resolve it quite a lot of time already, but the only answer I found somewhere was to install different ROM, even not explaining why do that, so I'm looking for a better alternative, and it's important for me to understand why this happen. So I will be super appriciate if you will help me to resolve this issue and/or explain, what's going on there.


Upd1: I could install app on device manually and it's run just fine, I could even debug it with AS, however if I make any change in code and then rerun application, it's still old version of code run on device, untill I manually remove old apk/install new one.

silent_coder
  • 6,222
  • 14
  • 47
  • 91
  • 1) Have you tried uninstalling the App? 2) Can you try and create a 2nd (test) app and deploy that to your phone? Doesn't have to be more then a "Hello World" thingy. It that 2nd one crashes also, you know it's (probably) in your phone, otherwise your code. – Flummox - don't be evil SE Jan 12 '17 at 16:06
  • Yes, I tryied uninstall app. However if I install it manually, I could later debug it in AS, but even in those case AS not updating it to newer code. And i'm already playing with default generated template without any complex code, so code/manifest/gradle config isn't an issue. – silent_coder Jan 12 '17 at 17:07
  • 1
    This answer should help, problems running the package manager (pm) http://stackoverflow.com/questions/30486705/android-studio-pm-install-aborted – Jon Goodwin Jan 15 '17 at 14:33
  • if you can run in simulator do one thing create a sign apk and try to run in your device and comment what happen...! – Arpan24x7 Jan 16 '17 at 10:34
  • @Arpan24x7 see question update. – silent_coder Jan 16 '17 at 11:13
  • @silent_coder can you just try one in AndroidManifest set again `OnlyTetstBBBAct` activity path ? – user1140237 Jan 16 '17 at 11:22
  • Try to turn off Instant Run if you have it on, and then rebuild/run the app. – Asim Jan 16 '17 at 11:34
  • @user1140237 Sorry, I don't get understand what you want to try. – silent_coder Jan 16 '17 at 11:38
  • @silent_coder have you face the same problem in any other device? or you may rebuild your app before run due to after AS 2.2 instance run may not be update your latest code. – Arpan24x7 Jan 16 '17 at 11:41
  • @Arpan24x7 Unfortunatelly I don't have other devices =( And I tryed with/without instant run, none of this not updating code and can't make "fresh" install. – silent_coder Jan 16 '17 at 11:53
  • My co-worker has a Xiaomi device too. In Windows 10, he need to install Xiaomi desktop application to make Android Studio recognize the device. Have you try to install the desktop app? – ישו אוהב אותך Jan 16 '17 at 12:20
  • @silent_coder if you don't mind may I use your code? – Arpan24x7 Jan 16 '17 at 12:38
  • @silent_coder may i know what drivers are you using ??? – PN10 Jan 16 '17 at 14:01
  • @ישואוהבאותך It's recognized by AS. – silent_coder Jan 17 '17 at 06:18
  • @Arpan24x7 Feel free, but which code? – silent_coder Jan 17 '17 at 06:19
  • @silent_coder the same code which you run in your xiaomi device and you have an issue. so I try to run in my device . (I have samsung S5, samsung Note 3, nexus 5 , Lenovo A319 , Lenovo K6 Power,Lenovo S580, Samsung T111 and N8000 and Htc 526 dule sim.) – Arpan24x7 Jan 17 '17 at 07:20
  • 1
    You could test if the pm utility on the device works by running `adb shell pm list` (in a terminal). It should output `usage: pm path [--user USER_ID] PACKAGE....` if pm works alright – Pär Nils Amsen Jan 17 '17 at 10:59
  • @Arpan24x7 I use just plain generated activity with fab. 2nd or 3rd template in AS, no custom changes. – silent_coder Jan 19 '17 at 12:23
  • This is the Android Runtime issue with MI 4c model. It is not giving to run the app using the command over the app. So can you check once the thing in a flow to verify issue: 1. Don't run app by command. Just build an apk and copy it in device storage and install it from there and check is it throwing same error? – Ready Android Jan 20 '17 at 09:23
  • @JonGoodwin and PärNilsAmsen have the right idea. The problem is with the Android Package Manager. Look at what they wrote. – Hod Jan 21 '17 at 22:13

3 Answers3

1

When I read the question I saw $ adb shell am start... and thought he's typing that, but no, this is auto-generated by AS and displayed in a log (my bad).


I (on purpose) made the package name incorrect by adding "XXX" in front of it like so:

adb shell am start -n "XXXcom.hotveryspicy.maskimage/info.androidhive.slidingmenu.SlidingMenuActivity"

Starting: Intent { cmp=XXXcom.hotveryspicy.maskimage/info.androidhive.slidingmenu.SlidingMenuActivity }

Error type 3 Error: Activity class {XXXcom.hotveryspicy.maskimage/info.androidhive.slidingmenu.SlidingMenuActivity} does not exist.

This gives the same error as you get (also if you get your path wrong to your Activity).
Are you 100% sure that you have the package name AND FULL path to your Activity correct?
Check your AndroidManifest.xml for full path to OnlyTetstBBBAct Activity and package name:

    package="com.example.ph.myapplication"
<activity android:name="com.example.ph.myapplication.OnlyTetstBBBAct" >

Post your AndroidManifest.xml so we check for silly mistakes, and hope it is not something hard to fix.
Getting your package name from an apk:

aapt dump badging <path-to-apk> 

(e.g. C:\Android\sdk\build-tools\25.0.0\aapt dump badging app-debug.apk)
Some useful commands:

adb uninstall com.example.ph.myapplication
adb -d install C:\Android\MaskActivity\app\build\outputs\apk\app-debug.apk
adb install -r app-debug.apk //(re-install preserving data)
adb shell rm /data/local/tmp/*.apk
adb devices
adb shell pm list packages

To see the logcat:

adb logcat

OR
open up a monitor to see the logcat:

C:\Android\sdk\tools\monitor
Jon Goodwin
  • 9,053
  • 5
  • 35
  • 54
  • Funny) 1. I wasn't able to make mistake with command, since it's generated by AS. No human changes. 2) It's possible to install apk file on device manually and than debug it with AS, if don't beleive me - just try yourself. But anyway, as I said, i'm trying generated template. However I check manifest and it's looks as it should be. To see my manifest just generate clean activity template by android studio project and you will see it. – silent_coder Jan 21 '17 at 14:01
  • The problem doesn't appear to be with OPs package. The error thrown is referencing `com.android.commands.pm.Pm`. So something is going wrong with the Android package manager. – Hod Jan 21 '17 at 21:52
0

Try adding following code to your build.gradle(app)

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

         defaultConfig {
             minSdkVersion 14 //lower than 14 doesn't support multidex
             targetSdkVersion 22

             // Enabling multidex support.
             multiDexEnabled true
         }
}

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}
Harmantj
  • 182
  • 2
  • 11
0

So, unfortunatelly I wasn't able to make it work without rooting the phone. However today I eventually root it, install adbd insecure, inside adbd insecure I checked all options and now it's all working as it should.

silent_coder
  • 6,222
  • 14
  • 47
  • 91