GamesNativeSDK "Could not load additional classes from embedded jar."

GamesNativeSDK "Could not load additional classes from embedded jar."

我正在尝试将 Google 游戏服务添加到我的本机 Android 游戏中。 gpg::GamesServices::Builder::Create 返回 NULL 并且以下内容打印在 logcat 中:

E/GamesNativeSDK(pid): Error emptying previous jar directory.
E/GamesNativeSDK(pid): Could not load additional classes from embedded jar.

我的原生代码很简单:

gpg::AndroidInitialization::JNI_OnLoad( javaVM );
gpg::AndroidPlatformConfiguration platform_configuration;
platform_configuration.SetActivity( activity );
gpg::GamesServices::Builder builder;
service = builder
    .SetOnAuthActionStarted([this](gpg::AuthOperation op) { OnAuthActionStarted(op); })
    .SetOnAuthActionFinished([this](gpg::AuthOperation op, gpg::AuthStatus status) { OnAuthActionFinished(op, status); })
    .EnableSnapshots()
    .Create(platform_configuration);

我的 project.properties 包含:

android.library.reference.3=extras/play_services/library

这是我放置 Google Play 服务库的地方。当我 运行 蚂蚁时,我看到它包括 extras/play_services/library/bin/classes.jarlib/google-play-services.jar

我没有使用混淆器。

原来你必须从 JNI_OnLoad 中调用 AndroidInitialization::JNI_OnLoad。初始化GPG时不能随便调用。

PieNoon 有一个很好的使用 JNI_OnLoad 的例子: https://github.com/google/pienoon/blob/master/src/gpg_manager.cpp