错误:com.google.android.gms.common.SignInButton无法实例化。

时间:2013-07-09 01:22:56

标签: android google-play-games

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

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

所以我有项目设置,我引用了google-play-services_libBaseGameUtils,因此MainActivity.java中没有出现任何错误,并且它们都会编译和构建好的,但布局编辑器继续吐出com.google.android.gms.common.SignInButton无法实例化。

我已经从下面的错误中粘贴了完整的堆栈跟踪。我想不出任何我缺少的东西,Eclipse中'Problems'窗口中唯一的东西是'应该明确地为清单设置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)

3 个答案:

答案 0 :(得分:2)

我有类似的问题,我也可以通过重启eclipse来解决它。但我对此为何起作用毫无头绪。这可能对某人有所帮助。

答案 1 :(得分:0)

添加这两个等级......问题将得到解决

compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.4.0'

答案 2 :(得分:-2)

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

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

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

如果已清理BaseGameUtils和Google Play服务库,定义为库并在项目中引用并编译好,那么问题可能在于您的模拟器。

你的模拟器上有Google API吗?

尝试重新启动模拟器。

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