1
votes

I've been struggling with an issue for days now. I'd recently switched over from Eclipse to Android Studio and after attempting to setup my new project with Google's games services (Leaderboards and achievements), I've noticed that a bunch of classes seem to be missing, while others are perfectly intact. I can login to googles services, I can display ads (another package, but it works perfectly none-the-less), and everything else seems to work fine; except loading intents. It appears as though the SDK manager has forgotten to include the 'com.google.android.gms.games.ui....' package into my sdk. Which means I can't load any intents (can't show leaderboards or achievements. My app doesn't crash, but I do get an error message and a bunch of "could not find class/could not load method" warnings in LogCat.

This is my log as soon as I attempt to call startActivityForResult(....) on the games settings intent for google games service, keep in mind the same errors pop up for leaderboards and achievements:

08-06 22:59:07.937 430-1614/? I/ActivityManager: START {act=com.google.android.gms.games.SHOW_SETTINGS dat=version:9452000 flg=0x4000000 pkg=com.google.android.play.games cmp=com.google.android.play.games/com.google.android.gms.games.ui.client.main.ClientSettingsActivity (has extras) u=0} from pid 10924 08-06 22:59:07.997 430-1615/? I/ActivityManager: Start proc com.google.android.play.games.ui for activity com.google.android.play.games/com.google.android.gms.games.ui.client.main.ClientSettingsActivity: pid=11180 uid=10086 gids={1028} E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.google.android.gms.games.ui.client.ClientFragmentActivity.instantiateGoogleApiClient** 08-06 22:59:08.317 11180-11180/? W/dalvikvm: VFY: unable to resolve new-instance 27 (Landroid/app/ActivityManager$TaskDescription;) in Lcom/google/android/gms/games/ui/client/ClientFragmentActivity; 08-06 22:59:08.327 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x22 at 0x0084 08-06 22:59:08.327 11180-11180/? D/dalvikvm: DexOpt: unable to opt direct call 0x007b at 0x86 in Lcom/google/android/gms/games/ui/client/ClientFragmentActivity;.instantiateGoogleApiClient 08-06 22:59:08.347 11180-11180/? W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/games/ui/GamesFragmentActivity$1; (55) 08-06 22:59:08.347 11180-11180/? W/dalvikvm: Link of class 'Lcom/google/android/gms/games/ui/GamesFragmentActivity$1;' failed 08-06 22:59:08.347 11180-11180/? E/dalvikvm: Could not find class 'com.google.android.gms.games.ui.GamesFragmentActivity$1', referenced from method com.google.android.gms.games.ui.GamesFragmentActivity.onCreate 08-06 22:59:08.347 11180-11180/? W/dalvikvm: VFY: unable to resolve new-instance 4724 (Lcom/google/android/gms/games/ui/GamesFragmentActivity$1;) in Lcom/google/android/gms/games/ui/GamesFragmentActivity; 08-06 22:59:08.347 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x22 at 0x0086 08-06 22:59:08.347 11180-11180/? I/dalvikvm: Could not find method android.view.Window.setStatusBarColor, referenced from method com.google.android.gms.games.ui.GamesFragmentActivity.updateStatusBar 08-06 22:59:08.347 11180-11180/? W/dalvikvm: VFY: unable to resolve virtual method 8409: Landroid/view/Window;.setStatusBarColor (I)V 08-06 22:59:08.347 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0030 08-06 22:59:08.347 11180-11180/? I/dalvikvm: Could not find method android.view.Window.setStatusBarColor, referenced from method com.google.android.gms.games.ui.GamesFragmentActivity.updateStatusBar 08-06 22:59:08.347 11180-11180/? W/dalvikvm: VFY: unable to resolve virtual method 8409: Landroid/view/Window;.setStatusBarColor (I)V 08-06 22:59:08.347 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0034 08-06 22:59:08.347 11180-11180/? E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.google.android.gms.games.ui.GamesFragmentActivity.updateTaskDescription 08-06 22:59:08.347 11180-11180/? W/dalvikvm: VFY: unable to resolve new-instance 27 (Landroid/app/ActivityManager$TaskDescription;) in Lcom/google/android/gms/games/ui/GamesFragmentActivity; 08-06 22:59:08.347 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x22 at 0x0040 08-06 22:59:08.347 11180-11180/? W/dalvikvm: Unable to resolve superclass of Lcom/google/android/gms/games/ui/GamesFragmentActivity$1; (55) 08-06 22:59:08.347 11180-11180/? W/dalvikvm: Link of class 'Lcom/google/android/gms/games/ui/GamesFragmentActivity$1;' failed 08-06 22:59:08.347 11180-11180/? D/dalvikvm: DexOpt: unable to opt direct call 0x6ab7 at 0x88 in Lcom/google/android/gms/games/ui/GamesFragmentActivity;.onCreate 08-06 22:59:08.347 11180-11180/? D/dalvikvm: DexOpt: unable to opt direct call 0x007c at 0x4f in Lcom/google/android/gms/games/ui/GamesFragmentActivity;.updateTaskDescription 08-06 22:59:08.357 11180-11180/? I/dalvikvm: Could not find method android.app.Activity.finishAfterTransition, referenced from method android.support.v4.app.FragmentActivity.onBackPressed 08-06 22:59:08.357 11180-11180/? W/dalvikvm: VFY: unable to resolve virtual method 88: Landroid/app/Activity;.finishAfterTransition ()V 08-06 22:59:08.357 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0012 08-06 22:59:08.377 963-1448/? D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 0ms 08-06 22:59:08.557 963-1448/? D/dalvikvm: GC_EXPLICIT freed 564K, 14% free 9888K/11399K, paused 4ms+6ms, total 179ms 08-06 22:59:08.577 11180-11180/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;) 08-06 22:59:08.577 11180-11180/? I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onSearchRequested 08-06 22:59:08.577 11180-11180/? W/dalvikvm: VFY: unable to resolve interface method 8386: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z 08-06 22:59:08.577 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 08-06 22:59:08.577 11180-11180/? I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.internal.view.WindowCallbackWrapper.onWindowStartingActionMode 08-06 22:59:08.577 11180-11180/? W/dalvikvm: VFY: unable to resolve interface method 8390: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode; 08-06 22:59:08.577 11180-11180/? D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002 08-06 22:59:08.597 892-894/? D/dalvikvm: GC_CONCURRENT freed 3308K, 27% free 14043K/19015K, paused 12ms+14ms, total 74ms 08-06 22:59:08.627 11180-11183/? D/dalvikvm: GC_CONCURRENT freed 230K, 5% E/AndroidUtils: getCallingContext(): couldn't find calling package name from com.google.android.gms.games.ui.client.main.ClientSettingsActivity@41d70410 08-06 22:59:08.867 11180-11180/? E/ClientUiFragAct: Client UI activities must be started with startActivityForResult 08-06 22:59:08.867 11180-11180/? E/GamesFragmentActivity: Unable to instantiate GoogleApiClient; bailing out...

Keep in mind, I've tried using different sdk targets (17, 21, 23, 24), I've tried mixing and matching different versions of libraries, I've tried adding all services and using only the minimum (games, plus, ads). I've tried everything I could possibly think of but I'm pretty new to gradle and I'm thinking I'm just overlooking something relatively simple. I just can't find a single hint on google using my logs and every variation of words I can think of to find a clue. Any help is appreciated.

Update:

This is where I call my showleaderboards method (in an update thread created for the game loop):

@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
    if (pSceneTouchEvent.isActionDown()) {

        GSGoogleServices.getInstance().showLeaderboards();

        return true;
    }

    return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
}

And this is the showLeaderboards method itself which starts the new activity which causes the error in logcat:

public void showLeaderboards(){
    if(mHelper.isSignedIn()){
        mActivity.startActivityForResult(Games.getSettingsIntent(getApiClient()), RC_UNUSED);
    } else {
        mHelper.beginUserInitiatedSignIn();
    }
}
1
Verify and dalvikvm warnings are nothing concerning. Can you include your actual code where you call startActivityForResult()? - ianhanniballake
I've updated the original question with my startActivityForResult method, and I should add those logs were captured using version 9.4.0 of google services, and build tools 24.0.1. Test devices being a samsung S5 running android 6.1 and an Asus transformer running android 4.1.1. Same result when using the previous services version and build tools 23. - Jay

1 Answers

0
votes

The solution has been found. I had RC_UNUSED in startacticityforresult set to -1 which starts a new activity without the context of the leaderboard activity class. Setting it to a non-negative value solved the issue