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.
Related
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.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vaibhav.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
...........................................................................
Above is my code , which looks fine but i don't know why I am getting the below Error ...
Unexpected error while executing: am start -n "com.example.vaibhav.myapplication/com.example.vaibhav.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER Error while Launching activity
.................
Also their is one thing , my , am start command is taking package name twice though it is declared correctly in
am start -n "com.example.vaibhav.myapplication/com.example.vaibhav.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category
You should use fully classified class name for activity in AndroidManifest.xml.
android:name
The name of the class that implements the activity, a subclass of Activity. The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity"). However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"), it is appended to the package name specified in the element.
For more info refer Android developer site
It looks like for some reason a wrong adb command is generated and being stuck in the project.
For me cleaning the project, closing then importing the project solved the problem.
Maybe even invalidate cashes and restart is also enough
I'm using Android Studio 2.1.3 (Mac OS X) and com.android.tools.build:gradle:2.1.3. I've already tried invalidating cache and restarting and clean builds.
I have a project with many ProductFlavors, all of which use the same starting activity save one (this one is a paid version that uses the licensing library, all the others are free so I don't bother, although a solution might just be to use the licensed version of the activity for all flavors but skip the licensing unless a resource is set... just seems too easy to hack). I thus have 2 AndroidManifest.xml files:
// app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.app">
...
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
android:name="com.company.app.TabsFragmentActivity"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
...
</application>
</manifest>
// app/src/PaidFlavor/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.app">
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher"
android:label="#string/appFriendlyName"
android:theme="#style/AppTheme">
<activity
tools:node="merge"
android:name="com.company.app.TabsFragmentActivityLicensed"
android:screenOrientation="portrait"
android:label="#string/appFriendlyName">
<intent-filter android:label="#string/launcherLabel">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
tools:node="remove"
android:name="com.company.app.TabsFragmentActivity"/>
</application>
</manifest>
This works great, and I can inspect the generated intermediate (merged) AndroidManifest.xml, and indeed the TabsFragmentActivity activity is removed, and the TabsFragmentActivityLicensed is added, and all is right with the world.
But I don't want the debug version (build type) to be licensed. Again, I can work around it easy enough in code, but it's the principle of the matter! So I thought it would be easy to just move
app/src/PaidFlavor/AndroidManifest.xml
to
app/src/PaidFlavorRelease/AndroidManifest.xml
This is where things go wrong. Everything builds without error, and I look at the intermediate (merged) manifest and it still looks correct. However, Android Studio tries to launch the PaidFlavor with release build type as:
adb shell am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Wrong activity! Where's it getting it from? Am I using the wrong subdirectory (PaidFlavorRelease/)? This results in the obvious error:
Error while executing: am start -n "com.company.project/com.company.app.TabsFragmentActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.company.project/com.company.app.TabsFragmentActivity }
Error type 3
Error: Activity class {com.company.project/com.company.app.TabsFragmentActivity} does not exist.
Error while Launching activity
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
I do have a curious error in my application.
My app crashes (don't mind the crash, I roughly know why - classloader) when I start the application from the OS directly, then kill it from the background via any Task Killer (this is one of the few ways to reproduce the crash consistently -> simulating the OS freeing memory and closing the application) and try to restart it again.
The thing is, if I start the application via adb shell using the following command:
adb shell am start -a android.intent.action.MAIN -n com.my.packagename/myLaunchActivity
I cannot reproduce the crash.
So is there any difference in how Android OS calls the application as opposed to the above call?
EDIT: added the manifest (just changed names)
<?xml version="1.0" ?>
<manifest android:versionCode="5" android:versionName="1.05" package="com.my.sample" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="7"/>
<application android:icon="#drawable/square_my_logo" android:label="#string/app_name">
<activity android:label="#string/app_name" android:name="com.my.InfoActivity" android:screenOrientation="landscape"></activity>
<activity android:label="#string/app_name" android:name="com.my2.KickStart" android:screenOrientation="landscape"/>
<activity android:label="#string/app_name" android:name="com.my2.Launcher" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/></manifest>
starting the com.my2.Launcher from the adb shell
First thing I can see is that if you launch the app from the launcher icon, the Intent includes the CATEGORY "android.intent.category.LAUNCHER" and using the adb shell am it does not.
Also, when you launch via the launcher icon, the Intent flag FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (0x200000) is set, in the adb shell case it is not.
Not sure if any of that would make a difference in your crash behaviour, but it answers the question.