4

I am trying to launch an application from the terminal emulator in Android, I can't seem to get the syntax or context of the command.

am start -n 

This is what I have.

The app is stored in /data/app folder

The app data is stored in /data/data folder

This is what I have tried.

am start -n /data/app/com.hcg.cok.gp-1.apk/ com.hcg.com.gp/ com.clash.of.kings.EmpireActivity

I know this is either a syntax error or a context error, can someone tell me what I'm doing wrong? This is the error I get from the shell.

u0_a250@trltetmo:/ $ su om.hcg.cok.gp-1.apk /.com.clash.of.kings.EmpireActivity < Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=/data/app/com.hcg.cok.gp-1.apk } Error type 3 Error: Activity class {/data/app/com.hcg.cok.gp-1.apk} does not exist. ta/com.hcg.cok.gp /com.clash.of.kings.EmpireActivity < Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=/com.clash.of.kings.EmpireActivity } Error type 3 Error: Activity class {/com.clash.of.kings.EmpireActivity} does not exist. root@trltetmo:/ #

I get other errors as I have tried everything I can think of to change what I am inputting. Here are all the different ways I have tried this.

    am start -n /data/data/com.hcg.cok.gp/ ./data/app/com.hcg.cok.gp/ .com/clash.of.kings.EmpireActivity
    am start -n /data/app/com.hcg.cok.gp-1.apk/ .EmpireActivity
    am start -n /data/app/com.hcg.cok.gp-1.apk/ ./data/data/com.hcg.cok.gp/ .com.clash.of.kings.EmpireActivity

I have literally tried this every way I can think of what do I have wrong? I need to launch this game from the shell so that I can pass input tap commands to it without them being interrupted by an income text, or email or any other event that would force the app into the background and ruin my Input flow to the game, I am building this in tasker and as long as my phone has nothing else to do my input commands from the shell work flawlessly, but if anything else happens in the system it pushes the game into the background and by the time it returns to the foreground the shell has now emulated taps but to the app that was dropped into the foreground d in front of the game, and it breaks what I am trying to do, so my idea here is if I can launch the game from the shell, and pass my input commands in the same shell it won't matter if the game is forced into the background because it is running inside the shell where my Input commands are also running. Sorry for the errors in some of the code, it is correct in my terminal but my phone is not liking the forums and keeps removing letters or changing case of them. I'm not near my computer so I can't fix these errors easily.

This is the entire manifest, I have the package and the activity correct, is it possible that it isn't launching because I have not set the UID of the shell? There is a line in the manifest that talks about checking for the user

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:"http://schemas.android.com/apk/res/android"         android:versionCode="708" android:versionName="1.1.10" android:installLocation="preferExternal" package="com.hcg.cok.gp" platformBuildVersionCode="22" platformBuildVersionName="5.1-1756733">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_DEVICE_STATS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.hcg.cok.gp.permission.C2D_MESSAGE" android:protectionLevel="signature|signatureOrSystem" />
<uses-permission android:name="com.hcg.cok.gp.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application android:label="@string/app_name" android:icon="@drawable/cok_icon" android:name="com.clash.of.kings.EmpireApplication" android:debuggable="false" android:largeHeap="true">
    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <activity android:theme="@style/MyTheme" android:label="@string/app_name" android:name="com.clash.of.kings.EmpireActivity" android:launchMode="standard" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
        <meta-data android:name="XINGCLOUD_CHANNEL" android:value="market" />
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="org.hcg.stac.empire.intent.action.IF" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="cok" />
        </intent-filter>
        <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_knjHdkLtLaoWWChZ9ZmCIgipAAnT53Wn" />
        <intent-filter>
            <data android:scheme="cokBranch" android:host="open" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>
    <meta-data android:name="com.facebook.sdk.ApplicationName" android:value="@string/app_name" />
    <activity android:theme="@*android:style/Theme.Translucent.NoTitleBar" android:label="@string/app_name" android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize" />
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
    <provider android:name="com.facebook.FacebookContentProvider" android:exported="true" android:authorities="com.facebook.app.FacebookContentProvider713457855362204" />
    <meta-data android:name="AdjustAppToken" android:value="cbc4rfy5xrad" />
    <meta-data android:name="AdjustLogLevel" android:value="info" />
    <meta-data android:name="AdjustEnvironment" android:value="production" />
    <meta-data android:name="AdjustEventBuffering" android:value="true" />
    <receiver android:name="com.appsflyer.AppsFlyerLib" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="it.partytrack.sdk.ReferrerReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.adjust.sdk.ReferrerReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.google.ads.conversiontracking.InstallReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.clash.of.kings.COKInstallReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.inmobi.commons.analytics.androidsdk.IMAdTrackerReceiver" android:enabled="true" android:exported="true">
        <intent-filter>
            <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            <action android:name="com.inmobi.share.id" />
        </intent-filter>
    </receiver>
    <activity android:theme="@*android:style/Theme.Translucent.NoTitleBar" android:name="com.inmobi.androidsdk.IMBrowserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize" android:hardwareAccelerated="true" />
    <service android:name="org.hcg.notifies.LocalNotificationIntentService" />
    <receiver android:name="org.hcg.notifies.LocalBroadcastReceiver" />
    <receiver android:name="org.hcg.stac.empire.common.manager.NotificationReceiver" android:process=":remote">
        <intent-filter>
            <action android:name="com.hcg.cok.intent.action.NOTIFICATION" />
            <action android:name="com.hcg.cok.intent.action.FREE_LOTTERY" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.analytics.tracking.android.CampaignTrackingService" />
    <meta-data android:name="UMENG_APPKEY" android:value="526f648856240b025f008fff" />
    <meta-data android:name="UMENG_CHANNEL" android:value="android_marekt_global" />
    <meta-data android:name="TESTIN_APPKEY" android:value="ed64e49e02a4441326ac32a2598cf0af" />
    <meta-data android:name="TESTIN_CHANNEL" android:value="android_marekt_global" />
    <meta-data android:name="com.parse.push.gcm_sender_id" android:value="id:312229299745" />
    <receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.hcg.cok.gp" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.hcg.cok.gp" />
        </intent-filter>
    </receiver>
    <service android:name="org.hcg.stac.empire.common.manager.GCMIntentService" />
    <activity android:name="com.umeng.api.activity.OauthActivity" android:screenOrientation="unspecified" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="10" />
    <activity android:theme="@style/Theme_IOSched" android:name="com.umeng.api.activity.UpdateStatusActivity" android:screenOrientation="unspecified" android:configChanges="keyboardHidden|orientation" android:windowSoftInputMode="14" />
    <activity android:name="com.tapjoy.TJCOffersWebView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.tapjoy.TapjoyFeaturedAppWebView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.tapjoy.TapjoyVideoView" android:configChanges="keyboardHidden|orientation" />
    <activity android:name="com.sponsorpay.sdk.android.publisher.OfferWallActivity" android:configChanges="orientation" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <service android:name="com.parse.PushService" />
    <receiver android:name="com.parse.ParseBroadcastReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.parse.push.intent.RECEIVE" />
            <action android:name="com.parse.push.intent.DELETE" />
            <action android:name="com.parse.push.intent.OPEN" />
        </intent-filter>
    </receiver>
    <receiver android:name="com.clash.of.notifies.HFParseCustomReceiver" android:exported="false">
        <intent-filter>
            <action android:name="com.hcg.cok.gp.UPDATE_STATUS" />
        </intent-filter>
    </receiver>
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__conversation_header" android:name="com.helpshift.HSConversation" android:configChanges="locale|orientation|screenSize|layoutDirection" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.HSQuestionsList" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__question_header" android:name="com.helpshift.HSQuestion" android:configChanges="orientation|screenSize" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.HSSection" android:configChanges="orientation|screenSize" android:windowSoftInputMode="20" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:label="@string/hs__help_header" android:name="com.helpshift.HSFaqs" android:configChanges="orientation|screenSize" android:windowSoftInputMode="20" android:hardwareAccelerated="true" />
    <activity android:theme="@style/Helpshift_Theme_Dialog" android:name="com.helpshift.HSReview" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.ScreenshotPreviewActivity" android:configChanges="orientation|screenSize" />
    <activity android:theme="@style/Helpshift_Theme_Activity" android:name="com.helpshift.SearchResultActivity" android:configChanges="orientation|screenSize" />
    <service android:label="Helpshift Service" android:name="com.helpshift.HSService" />
    <service android:label="Helpshift Service" android:name="com.helpshift.HSRetryService" />
    <meta-data android:name="com.vk.sdk.AppId" android:value="5024256" />
    <activity android:name="com.vk.sdk.VKOpenAuthActivity" />
    <activity android:theme="@style/VK_Transparent" android:label="ServiceActivity" android:name="com.vk.sdk.VKServiceActivity" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ChatActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ChannelListActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.ForumActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.MemberSelectorActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <activity android:theme="@style/Activity_Theme" android:name="com.elex.chatservice.view.WriteMailActivity" android:screenOrientation="portrait" android:configChanges="locale|orientation|screenSize" />
    <meta-data android:name="io.fabric.ApiKey" android:value="a9561a0f09e88d758810060aea57aac008e89d0c" />
    <meta-data android:name="io.branch.sdk.BranchKey" android:value="key_live_knjHdkLtLaoWWChZ9ZmCIgipAAnT53Wn" />
</application>

manfcas
  • 1,933
  • 7
  • 28
  • 47
Casey French
  • 139
  • 2
  • 5
  • 14
  • Is the app you are trying to launch is already installed? (you said it is in data/app folder, what does it mean?) – Darpan Oct 30 '15 at 06:55
  • 1
    Yes the app is already installed and I guess instead of mounting it in the app/asec folder or using the app/app-private folder the developer chose to load all the libraries and resource folders in /data/data/com.hcg.cok.gp while the app package (apk) its self is loaded in the data/app/com.hcg.cok.gp-1.apk folder – Casey French Oct 30 '15 at 13:33

3 Answers3

3

From your command, I reckon that you are installing the app and launching both in one command?

if yes, it is not possible. You will have to install using one command -

adb install package.name

and to run your activity -

adb shell am start -n com.package.name/com.package.name.ActivityName

where your package name seems - com.hcg.cok.gp

where your activity name seems - com.clash.of.kings.EmpireActivity

Reference

Community
  • 1
  • 1
Darpan
  • 5,623
  • 3
  • 48
  • 80
  • Okay, so that is where I am messing up, no Iam not trying to install it and launch it, it is already installed iI just need to launch it so if I'm ready correctly I need this. – Casey French Oct 30 '15 at 13:17
  • am start -n /data/data/com.hcg.cok.gp/com.hcg.cok.gp.clash.of.kings.EmpireActivity. – Casey French Oct 30 '15 at 13:20
  • Where your example says .ActivityName am I missing the boat assuming I need the full com.clash.of.kings.EmpireActivity? Because I'm still getting the same error with it typed as. am start -n /data/app/com.hcg.cok.gp-1.apk/com.hcg.cok.gp.com.clash.of.kings.EmpireActivity. – Casey French Oct 30 '15 at 13:36
  • I doubt your package name contains '.apk' as well/ – Darpan Oct 30 '15 at 14:31
  • I get the same error with. am start -n com.hcg.cok.gp/com.hcg.cok.gp.com.clash.of.kings.EmpireActivity. does this maybe not work with an app that isn't debuggable? – Casey French Oct 30 '15 at 15:08
  • here is the thing, in your androidManifest file, check for 'package' right in 'manifest' tag, that is your package. Because your activity starts with 'com.clash.of.kings.EmpireActivity' and package as you say is com.hcg.cok.gp'.. – Darpan Oct 30 '15 at 15:22
  • As you can see from the manifest, the package name and the activity name are correct, what else could be causing this? An applet in Busybox that needs to be updated or installed possibly? – Casey French Oct 30 '15 at 20:07
  • final try - `adb shell am start -n com.hcg.cok.gp/com.clash.of.kings.EmpireActivity` it should work, else this method does not work I guess – Darpan Oct 31 '15 at 20:41
2

am start -n com.package.name/.ActivityName

5c0tt
  • 21
  • 3
0

You can use the am start command trough adb.An Example for the browser app floating around the internet:

am start -a android.intent.action.MAIN -n com.android.browser/.BrowserActivity 
Mrad Mrad
  • 542
  • 4
  • 14