5

We have integrated Google Play Services C++ SDK (1.1) into our Android app. Our testing physical device is Android API 4.0.3. The Google Play Services works and Players are able to access, unlock achievements and leaderboard.

However, we got a problem that we are unable to auto sign in during startup with error code -3. After the app started, we are able to login 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 initialized Game Services in OnCreate method. The following codes show the related implementation. Noted that our app extended standard Java Activity.

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

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

The methods refer to C++ methods as follow

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");
}
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.