GamesNativeSDK“无法从嵌入式jar中加载其他类。”

时间:2015-01-13 00:29:24

标签: android google-play-services google-play-games

我正在尝试将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服务库放在哪里。当我运行ant时,我会看到它包括extras/play_services/library/bin/classes.jarlib/google-play-services.jar

我没有使用proguard。

1 个答案:

答案 0 :(得分:1)

原来你必须从JNI_OnLoad中调用AndroidInitialization :: JNI_OnLoad。如果要初始化GPG,则无法任意调用它。

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