I am trying to get the android ui monkey running for the first time and am having some problems.
I have run adb shell monkey -v 100 which works fine, but obviously only on the system UI not on my own application.
I then try
adb shell monkey -p com.rbennett485.dawnoftheveg -v 100
and get the output
:Monkey: seed=1406692871132 count=100
:AllowPackage: com.rbennett485.dawnoftheveg
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
** No activities found to run, monkey aborted.
The relevant section of my manifest is
<activity
android:name="com.rbennett485.dawnoftheveg.DawnOfTheVeg"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
Any ideas? I know a lot has been asked about this error before, but it mostly seems to be from not using the full package name - am I using the correct package name here?
Turned out the package my main activity was in had a different name to the package that was defined in my manifest. By using the manifest package name instead it worked fine
Related
I know it's a duplicated question but any solution I tried not resolved the problem.
The real question is there's a way to launch the app when the activity alias is enabled? I mean, my app has a feature to change the icon launcher for certain users and I want to build the app and launch it when the icon has changed, so the activity alias is enabled.
here's the error:
Error while executing: am start -n "SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=SplashScreenActivity }
Error type 3
Error: Activity class {SplashScreenActivity} does not exist.
Error while Launching activity
Failed to launch an application on all devices
Here's my manifest:
<activity
android:name="SplashScreenActivity"
android:configChanges="orientation|keyboardHidden"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity-alias
android:name="SplashScreenActivityAlias"
android:icon="#mipmap/ic_launcher_prime"
android:label="#string/app_name_app"
android:enabled="false"
android:targetActivity="SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>
I saw some resolutions that I need uninstall the app but I want to just build and launch as the app normally do.
You haven't fully qualified the component, so it doesn't know where to find it. You need to provide the package name for your Activity, like this:
am start -n "my.package.name/.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Note: I have used "my.package.name" for the package. You need to replace that with your app's package name, as you have it in the manifest. Also note the "." (period, dot) character after the "/" (slash) character before SplashScreenActivity.
I think my issue has something to do with the adb. I searched a lot online and tried to shut it down about 4 different ways and nothing helps. I am using a Mac. Here is what the Run tab of Android Studio says when I run my app:
06/16 16:36:06: Launching app
$ adb push /Users/melloo/Desktop/UCI/Intro-to-Mobile-App-Development-with-
Android/A2-Antoniya.Puleva/app/build/outputs/apk/app-debug.apk
/data/local/tmp/x40240.antoniya.puleva.a2
$ adb shell pm install -r "/data/local/tmp/x40240.antoniya.puleva.a2"
pkg: /data/local/tmp/x40240.antoniya.puleva.a2
Success
$ adb shell am start -n
"x40240.antoniya.puleva.a2/x40240.antoniya.puleva.a2.MainActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 2983 on device Nexus_5X_API_22 [emulator-5554]
Application terminated.
and my manifest:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:launchMode="standard"
>
<activity android:name=".MainActivity"
android:label="List O'Names">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NameListActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name = "x40240.antoniya.puleva.intent.action.ACTION_VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
</application>
Had similar error using Android Studio 3.0 Canary 3. Try doing following things:
Update your Android Studio to the latest version (if you are using 3.0, Canary 4 just came out yesterday)
I see you are using Emulator with Lolipop (api 22), try creating new device with api 25 (Nougat)
Try doing some change in manifest (like adding empty line, the point is to just change the manifest file), then go Build->Clean project and to run it again.
I created a splash screen for my android application. In my AndroidManifest I set the SplashScreen Activity as Launcher and action as MAIN. After that I changed the HomeActivity's intentfilter.
Here is my android manifest file:
<application
android:allowBackup="true"
android:icon="#mipmap/icon"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".SplashScreenActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ActivityHome"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.ACTIVITHOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name=".Receivers.NetworkReceiver"></receiver>
</application>
I have both these activities inside the default package. Now, when I try to test the application in device, I get the following error:
Error while executing: am start -n "com.sdz.myapp/com.sdz.myapp.SplashScreenActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sdz.myapp/.SplashScreenActivity }
Error type 3
Error: Activity class {com.sdz.myapp/com.sdz.myapp.SplashScreenActivity} does not exist.
Error while Launching activity
This is how my project structure looks like:
src
-com.sdz.myapp
----ActivityHome
----SplashScreenActivity
I restarted android studio but still the error is there. I dont know what is causing this.
I ran into this as well. I actually had to uninstall the apk from the device before it would work... which was really odd as the app wasn't showing up on my list of apps on the phone.
Here's what I did:
Opened up command line
Ran 'adb devices' to make sure my device was connected
ran 'adb uninstall ' Replace with "com.whatever.blah"
You should see a message saying it uninstall successfully
Try installing from Android Studio again and it should work
I have no idea how it gets in this weird state. :-/
Please change your android:name value at your activity tag with full name and first clean project . After that try to run your application again
<activity android:name="com.sdz.myapp.SplashScreenActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have this same issue occasionally. The solution was to build the APK (menu "Build > Build APK") and install it manually in the phone. After that the error disappears.
I tried all of the above plus even delete the build folder and still did not work. The solution for me was: On your Android Studio go to File->Sync Project with Gradle Files
I'm trying to start an Android application using adb shell.
I'm not succeeding
The AndoridManifest.XML is pasted below:
<?xml version="1.0" encoding="UTF-8"?>
<manifest android:versionCode="4" android:versionName="0.0.5.0" android:installLocation="auto" package="com.supascale.supascale" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="#string/app_name" android:icon="#drawable/i_c_o_n_e________1">
<activity android:theme="#android:style/Theme.Translucent" android:label="#string/app_name" android:name=".wdgen.GWDPSupaScale_Android$WDLanceur">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
I tried the following call:
adb shell am start -a android.intent.action.MAIN -n com.supascale.supascale/com.supascale.supascale.wdgen.GWDPSupaScale_Android
This does'nt work ... I've tried all sorts of itterations after the ... /
I get Error type 3, the intent class does not exist!
Any help will be greatly appreciated.
Regards
Adrian
Some of my error messages:
You should escape the $ - \$ - since otherwise it gets changed to nothing. $WDLanceor is interpreted as a shell variable by the android shell, and since the variable is not set it becomes an empty string.
Quoting the arguments (adb ... -n "... GWDPSupaScale_Android$WDLanceur") will only quote it on the Windows side, when it goes into the shell on the android side it'll be without quotes. The backslash will survive the Windows command prompt and be converted to an actual $ on the android shell.
How do I use the categories option of the monkey tool?
The relevant portion of my manifest file looks like this:
<application android:icon="#drawable/icon" android:label="#string/app_name" android:name="MyApp" android:debuggable="true" android:allowBackup="false" android:testOnly="false">
<activity android:name="MyLauncherActivity" android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="MyMainActivity" android:label="#string/app_name" android:screenOrientation="portrait">
<intent-filter>
<action android:name="none" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
</activity>
I run the application on my phone to make sure it is working then I enter this at the command line:
adb shell monkey -p my.full.package.path -vvv 3
It works just fine.
But this doesn't work:
adb shell monkey -p my.full.package.path -c intent.CATEGORY_LAUNCHER -vvv 3
and yields the following output:
:Monkey: seed=0 count=3
:AllowPackage: myapp.full.package.path
:IncludeCategory: intent.CATEGORY_LAUNCHER
// Warning: no activities found for category intent.CATEGORY_LAUNCHER
** No activities found to run, monkey aborted.
And trying some variants also didn't work:
:Monkey: seed=0 count=3
:AllowPackage: my.full.package.path
:IncludeCategory: CATEGORY_MONKEY
:IncludeCategory: intent.CATEGORY_MONKEY
:IncludeCategory: android.intent.MONKEY
:IncludeCategory: android.intent.category.MONKEY
:IncludeCategory: MONKEY
// Warning: no activities found for category CATEGORY_MONKEY
// Warning: no activities found for category intent.CATEGORY_MONKEY
// Warning: no activities found for category android.intent.MONKEY
// Warning: no activities found for category MONKEY
** No activities found to run, monkey aborted.
How do I specify categories
You're really close. This worked for me:
adb shell monkey -p com.JamesBecwar.test -c android.intent.category.LAUNCHER -vvv 3
I think the problem is that you need to include the Launcher too, because if you don't monkey can't start the program. Don't worry you can put more then one -c param. For example you could do:
adb shell monkey -p com.JamesBecwar.test -c android.intent.category.LAUNCHER -c android.intent.category.MONKEY -vvv 3
and it should work.
As far as I can understand by looking at the Monkey source code is that the -c argument stands for "main-category", it will only work in combination with a main-action. That the -c/main-categories criteria will only work when the monkey tries to start the app with "Implicit Intents" and not "Explicit Intents" within the app.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.MONKEY" />
</intent-filter>
https://android.googlesource.com/platform/development/+/master/cmds/monkey/src/com/android/commands/monkey/Monkey.java