我正在尝试将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.jar
和lib/google-play-services.jar
我没有使用proguard。
答案 0 :(得分:1)
原来你必须从JNI_OnLoad中调用AndroidInitialization :: JNI_OnLoad。如果要初始化GPG,则无法任意调用它。
PieNoon有一个使用JNI_OnLoad的好例子: https://github.com/google/pienoon/blob/master/src/gpg_manager.cpp