android - "You have not specified a View to use as content for popups"

标签 android gradle libgdx google-play-services

所以我一直在尝试在我的游戏中实现排行榜/成就,并且在没有任何类型的实现的情况下,游戏运行得很好。我已成功导入 google-play-services-lib 并通过 BaseGameUtils 进行复制。但是每当我尝试调用 GameHelper 对象的设置时,它就会崩溃。 LogCat 给出以下错误:

getCSCPackageItemText() 您尚未指定 View 用作弹出窗口的内容 View 。回退到 Activity 内容 View ,此 API 的 future 版本可能无法正常工作。使用 setViewForPopups() 设置内容 View 。 关闭虚拟机。

再往下一点,也会出现这个错误:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.packagename.AndroidLauncher}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content

然而,我看到的所有关于将 GPGS 与 libGDX 集成的教程都没有使用这些函数中的任何一个。我已经尝试在我的主视图上实现 setViewForPopups(我正在使用 Mopub 做广告,所以我将两个 View 放入一个布局中),但它似乎没有任何改变。这是我的 onCreate 方法中似乎导致崩溃的部分:

   super.onCreate(savedInstanceState);
   gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
   gameHelper.enableDebugLog(false);
   GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() {
        @Override
        public void onSignInSucceeded() {
        }

        @Override
        public void onSignInFailed() {
        }
   };
   gameHelper.setup(gameHelperListener); //This line causes the error. Removing it lets it work just fine.

我到处搜索,似乎没有其他人专门遇到这个问题。有什么建议吗?我使用的是最新版本的 google-play-services-lib 和 BaseGameUtils。

最佳答案

我想通了。原来我所要做的就是将 gameHelper.setup 调用移动到 onCreate 方法的最后,它工作得很好。

关于android - "You have not specified a View to use as content for popups",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25923638/

相关文章:

android - 带有 Snackbar 和透明导航栏的 FloatingActionButton

android - Genymotion - 从经度和纬度获取地址

android-studio - 如何在 Android Studio 中使用 Flutter RP2 清理您的构建?

eclipse - Gradle 任务在 Eclipse 中被禁用

java - libGDX:如何处理 Tiled 对象层中 Sprite 的碰撞?

java - 使用 TextureRegion (LibGDX) 在 Java 中绘制部分 Sprite

android - 如何使用命令行(CMD)冷启动模拟器

java - 从 imageview 触摸点,您可以调整 MAT 的大小以获得该点的颜色吗?

gradle - 来自新的Android开发人员:我一直收到错误消息 “Gradle Sync Failed: The first result from the daemon was empty”

java - 为什么我的程序不从 arrayList 中绘制房屋?