0

I have a third party game application which works fine by itself. Here is the original AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"     android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" package="com.thirdpartycompany.appname">

    ......

    <application android:debuggable="false" android:icon="@drawable/app_icon" android:label="@string/app_name">
        <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.abc.ThirdPartyActivity" android:screenOrientation="fullSensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
            </intent-filter>

        ......

        </activity>

        ......

        <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 1095208937458"/>
        <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 1095208937458"/>

        ......

    </application>

    ......

</manifest>

I then added another activity MyActivity and added the following code:

        Intent intent = new Intent();
        intent.setClassName("com.thirdpartycompany.appname", "com.abc.ThirdPartyActivity");
        startActivityForResult(intent, 7774);

Here is the new AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" package="com.thirdpartycompany.appname">
    <application android:debuggable="false" android:icon="@drawable/app_icon" android:label="@string/app_name">
        <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:name="com.abc.ThirdPartyActivity" android:screenOrientation="fullSensor">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.mycompany.MyActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 1095208937458" />
        <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 1095208937458" />        
    </application>            
</manifest>

When I launch the new application, I got the following exception:

FATAL EXCEPTION [main]
Unity version     : 4.5.5f1
Device model      : intel I861B3L2CA51
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys
 - [FATAL EXCEPTION [main]
Unity version     : 4.5.5f1
Device model      : intel I861B3L2CA51
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys
] : java.lang.Error: FATAL EXCEPTION [main]
Unity version     : 4.5.5f1
Device model      : intel I861B3L2CA51
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys

Caused by: java.lang.IllegalStateException: A fatal developer error has    occurred. Check the logs for further information.
    at com.google.android.gms.internal.hb$h.b(Unknown Source)
    at com.google.android.gms.internal.hb$h.d(Unknown Source)
    at com.google.android.gms.internal.hb$b.fv(Unknown Source)
    at com.google.android.gms.internal.hb$a.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5258)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

I searched on google and found Initializing Games Client in Android and I can't initialize Google Play game service. The suggested solution is to add

    <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="@string/app_id" />

to AndroidManifest.xml. I already have those two lines in my AndroidManifest.xml but still got the same exception. Does anyone know what has happened here? Thanks!

Community
  • 1
  • 1
user3869992
  • 31
  • 1
  • 5
  • In your Manifest, you added: "com.mycompany.MyActivity".. It should not be "com.thirdpartycompany.MyActivity"? Is the package name correct? – guipivoto Jul 28 '16 at 20:20
  • "com.mycompany.MyActivity", "com.abc.ThirdPartyActivity" and "com.thirdpartycompany.appname" are all right. The issue might be related to Google Play Game Service but the original application works well. – user3869992 Jul 29 '16 at 13:39

1 Answers1

0

If you try with:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.thirdpartycompany.appname");
if (launchIntent != null) { 
    startActivity(launchIntent);
}

Do you have the same result?

jos
  • 1,070
  • 12
  • 22
  • If I try that, will it launch MyActivity instead of com.abc.ThirdPartyActivity? I need to launch com.abc.ThirdPartyActivity from inside of MyActivity. – user3869992 Jul 28 '16 at 21:08
  • Oh yes, sorry . It will launch the activity declared in AndroidManifest.xml . – jos Jul 29 '16 at 07:24
  • I found this, but i never try it. So, glad if you post if it works! :) Intent intent = new Intent(); intent.setComponent(new ComponentName("com.thirdpartycompany.appname", "com.abc.ThirdPartyActivity")); startActivity(intent); – jos Jul 29 '16 at 07:25
  • If the ThirdPartyActivity (i.e. the original game application) does not use Google Play Game Service, the code inside MyActivity works fine and it was able to launch ThirdPartyActivity. I verified this with other game applications. I suspect the issue is related to Google Play Game Service but can't figure out why. – user3869992 Jul 29 '16 at 13:32