1

我正在尝试运行 Google Play 游戏服务示例,但这样做时遇到了很多麻烦。

最初,尝试通过 Eclipse 中的“将现有代码导入工作区”打开现有代码项目会导致各种我无法弄清楚的错误。即 R.java 没有构建。我可以通过创建一个空白项目并复制粘贴所有代码和资源文件来解决这个问题。

所以我已经设置了项目,并且我已经引用了google-play-services_liband BaseGameUtils,所以在 MainActivity.java 中没有出现错误,并且它都可以编译和构建,但是布局编辑器不断吐出com.google.android.gms.common.SignInButton无法实例化。

我从下面的错误中粘贴了完整的堆栈跟踪。我想不出我遗漏的任何东西,Eclipse 中“问题”窗口中唯一的内容是清单的“应明确将 android:allowBackup 设置为 true 或 false”。

android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F02000C.
at android.content.res.BridgeResources.throwException(BridgeResources.java:693)
at android.content.res.BridgeResources.getDrawable(BridgeResources.java:164)
at com.google.android.gms.internal.aa.b(Unknown Source)
at com.google.android.gms.internal.aa.a(Unknown Source)
at com.google.android.gms.common.SignInButton.c(Unknown Source)
at com.google.android.gms.common.SignInButton.d(Unknown Source)
at com.google.android.gms.common.SignInButton.setStyle(Unknown Source)
at com.google.android.gms.common.SignInButton.<init>(Unknown Source)
at com.google.android.gms.common.SignInButton.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:749)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:385)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:440)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreview.renderSync(RenderPreview.java:560)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreview.access$5(RenderPreview.java:506)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreview$RenderJob.runInUIThread(RenderPreview.java:1230)
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4144)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1053)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:942)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:588)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:543)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
4

3 回答 3

2

我有一个类似的问题,我也可以通过重新启动 Eclipse 来解决它。但我不知道为什么会这样。这可能对某些人有所帮助。

于 2014-06-16T04:43:18.830 回答
0

添加这两个gradle ...问题将解决

compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'
于 2016-01-29T18:26:37.650 回答
-1

我现在专注于跟踪的第一行:

android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F02000C.

无论其他可能有错或可能没有错,您都需要解决此问题。首先,您是否确信您的项目不会缺少任何资源?即你以一种不同寻常的方式构建了这个项目,如果你错过了什么也不足为奇。

如果 BaseGameUtils 和 Google Play Services 库已被清理,定义为库并在您的项目中引用并编译正常,那么问题可能出在您的模拟器上。

你的模拟器上有谷歌API吗?

尝试重新启动模拟器。

如果一切正常,我建议您查看此文档以及从中链接的“故障排除指南”: https ://github.com/playgameservices/android-samples/blob/master/README.md并考虑从头开始仔细检查每一步。

于 2013-07-09T14:02:25.697 回答