Unable to auto-sign on Google Play Game Services (play C ++ SDK games)

We have integrated Google Play Services C ++ SDK (1.1) into our Android app. Our physical test device is Android API 4.0.3. Google Play services are operational and players can access, unlock achievements and leaderboards.

However, we ran into a problem where we are unable to automatically login on startup with error code -3. After launching the application, we can log in manually. The following logCat records were captured during startup.

08-07 09:31:34.045  6724  6724 I main    : Initializing Services
08-07 09:31:34.045  6724  6724 I main    : Uninitialized services, so creating
08-07 09:31:34.139  6724  6724 I dalvikvm: Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1.h
08-07 09:31:34.139  6724  6724 W dalvikvm: VFY: unable to resolve virtual method 5238: Landroid/view/View;.getDisplay ()Landroid/view/Display;
08-07 09:31:34.139  6724  6724 I dalvikvm: Could not find method android.view.ViewTreeObserver.removeOnGlobalLayoutListener, referenced from method com.google.android.gms.games.internal.PopupManager$PopupManagerHCMR1.g
08-07 09:31:34.139  6724  6724 W dalvikvm: VFY: unable to resolve virtual method 5417: Landroid/view/ViewTreeObserver;.removeOnGlobalLayoutListener (Landroid/view/ViewTreeObserver$OnGlobalLayoutListener;)V
08-07 09:31:34.139  6724  6724 W PopupManager: You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
08-07 09:31:34.139  6724  6724 I main    : Created
08-07 09:31:34.139  6724  6753 I GamesNativeSDK: Connecting to Google Play...
08-07 09:31:34.928  6724  6724 I dalvikvm: Could not find method android.webkit.WebSettings.getDefaultUserAgent, referenced from method afz.a
08-07 09:31:34.928  6724  6724 W dalvikvm: VFY: unable to resolve static method 3655: Landroid/webkit/WebSettings;.getDefaultUserAgent (Landroid/content/Context;)Ljava/lang/String;
08-07 09:31:34.967  6724  6724 I Ads     : Starting ad request.
08-07 09:31:35.084  6724  6724 I Ads     : Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
08-07 09:31:35.100  6724  6724 I dalvikvm: Could not find method android.webkit.WebSettings.setMediaPlaybackRequiresUserGesture, referenced from method agk.<init>
08-07 09:31:35.100  6724  6724 W dalvikvm: VFY: unable to resolve virtual method 3670: Landroid/webkit/WebSettings;.setMediaPlaybackRequiresUserGesture (Z)V
08-07 09:31:35.475   405   436 I AlarmManager: sending alarm Alarm{41c0fbc0 type 2 com.android.phone}, PendingIntent{420f7740: PendingIntentRecord{41caf830 com.android.phone broadcastIntent}}
08-07 09:31:36.287  6724  6765 E GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
08-07 09:31:36.647   405   437 I ActivityManager: Displayed com.MyApp.app/org.cocos2dx.cpp.AppActivity: +4s610ms
08-07 09:31:36.670  6724  6753 I GamesNativeSDK: UI interaction required to connect to Google Play.
08-07 09:31:36.670  6724  6754 I main    : Sign in finished with a result of -3

      

We have initialized the game services in the OnCreate method. The following codes show the corresponding implementation. It is noted that our application extends the standard Java activity.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    nativeInitGPGS(this); // create Google Player Services
    nativeOnActivityCreated(this, savedInstanceState); 
}

      

Methods refer to C ++ methods as follows

JNIEXPORT void
Java_org_cocos2dx_cpp_AppActivity_nativeInitGPGS(JNIEnv* env, jobject thiz, jobject activity)
{
    gpg::AndroidPlatformConfiguration platform_configuration;
    platform_configuration.SetActivity(activity);
    GPGSManager::InitServices(platform_configuration);
}

JNIEXPORT void
Java_org_cocos2dx_cpp_AppActivity_nativeOnActivityCreated(
 JNIEnv* env, jobject thiz, jobject activity, jobject saved_instance_state) {
     gpg::AndroidSupport::OnActivityCreated(env, activity, saved_instance_state);
}

void GPGSManager::InitServices(gpg::PlatformConfiguration &pc)
{
    LOGI("Initializing Services");
    if (!gameServices) {
    LOGI("Uninitialized services, so creating");
    gameServices = gpg::GameServices::Builder()
        .SetLogging(gpg::DEFAULT_ON_LOG, gpg::LogLevel::VERBOSE)
        .SetOnAuthActionStarted([](gpg::AuthOperation op){
            OnAuthActionStarted(op);
        })
        .SetOnAuthActionFinished([](gpg::AuthOperation op, gpg::AuthStatus status){
            LOGI("Sign in finished with a result of %d", status);
            if( status == gpg::AuthStatus::VALID )
                isSignedIn = true;
            else
                isSignedIn = false;
            OnAuthActionFinished( op, status);
        }).Create(pc);
    }
    LOGI("Created");
}

      

+3


source to share





All Articles