在android中引入-google-places-api示例的问题

发布于 2024-11-15 22:42:47 字数 1511 浏览 4 评论 0原文

我正在尝试通过 Android 应用程序的 Google API 客户端使用 Google Places API。我找到了这个示例: http://ddewaele.blogspot .com/2011/05/introducing-google-places-api.html 并像 java 应用程序一样启动运行正常,所以我必须有一个正确的 API 密钥。 我正在使用 eclipse 和 maven,一切似乎都正常,但是当应用程序像 Android 应用程序一样启动时,模拟器运行正常,但显示以下错误: 应用程序应用程序名称 (com.ecs.googleplaces.sample.Main) 意外停止。请再试一次。 我已经看到了这个答案 创建 Google HTTP 传输对象对于 Android HTTP 请求,我已经编写了所有依赖项(还有更多,以及一些较新版本的依赖项) 我的 LogCat 中有一个粘贴:

06-17 13:58:40.442: ERROR/Zygote(33): setreuid() failed. errno: 2
06-17 13:58:51.091: ERROR/Zygote(33): setreuid() failed. errno: 17
06-17 13:58:52.272: ERROR/BatteryService(61): usbOnlinePath not found
06-17 13:58:52.272: ERROR/BatteryService(61): batteryVoltagePath not found
06-17 13:58:52.272: ERROR/BatteryService(61): batteryTemperaturePath not found
06-17 13:58:52.292: ERROR/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
06-17 13:58:52.402: ERROR/SensorService(61): couldn't open device for module sensors (Invalid argument)
06-17 13:58:57.061: ERROR/System(61): Failure starting core service
06-17 13:58:57.061: ERROR/System(61): java.lang.SecurityException
06-17 13:58:57.061: ERROR/System(61):     at android.os.BinderProxy.transact(Native Method)
....

有人可以帮助我吗? 谢谢

I'm trying to use Google Places API through Google APIs Client for an Android app. I've found this example: http://ddewaele.blogspot.com/2011/05/introducing-google-places-api.html and launching like java application runs OK, so I must have a right API KEY.
I'm using eclipse and maven and all seems ok, but when the application is launched like Android app, the emulator runs ok but shows the following error:
The application Application Name (com.ecs.googleplaces.sample.Main) has stopped unexpectedly. Please try again.
I've seen that answer Creating a Google HTTP Transport Object for Android HTTP Request and I have all the dependencies there written (and more, and some of the with newer versions)
There is a paste from my LogCat:

06-17 13:58:40.442: ERROR/Zygote(33): setreuid() failed. errno: 2
06-17 13:58:51.091: ERROR/Zygote(33): setreuid() failed. errno: 17
06-17 13:58:52.272: ERROR/BatteryService(61): usbOnlinePath not found
06-17 13:58:52.272: ERROR/BatteryService(61): batteryVoltagePath not found
06-17 13:58:52.272: ERROR/BatteryService(61): batteryTemperaturePath not found
06-17 13:58:52.292: ERROR/SurfaceFlinger(61): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
06-17 13:58:52.402: ERROR/SensorService(61): couldn't open device for module sensors (Invalid argument)
06-17 13:58:57.061: ERROR/System(61): Failure starting core service
06-17 13:58:57.061: ERROR/System(61): java.lang.SecurityException
06-17 13:58:57.061: ERROR/System(61):     at android.os.BinderProxy.transact(Native Method)
....

Can anyone help me?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浸婚纱 2024-11-22 22:42:47

Logcat 未显示与 Places API / API 密钥相关的任何内容。
该示例还应该可以在 Android 上几乎开箱即用。您唯一需要考虑的是 Android 上使用的 HTTP 传输。根据您的 API 级别,Google 建议使用特定的 HTTP 传输。

适用于 Java 的 Google API 客户端提供了一个实用方法,可根据您的 Android 运行时返回正确的 HttpTransport。

HttpTransport transport = AndroidHttp.newCompatibleTransport(); 

也许您还错过了 logcat 中的堆栈跟踪,其中包含崩溃的实际原因。尝试在 logcat 中搜索您的应用程序包。

The Logcat isn't showing anything related to the Places API / API key.
The sample should also work pretty much out of the box with Android. The only thing you need to consider is the HTTP Transport used on Android. Depending on your API level, Google recommends using specific HTTP transports.

The Google API client for Java offers a utility method to return the correct HttpTransport based on your Android runtime.

HttpTransport transport = AndroidHttp.newCompatibleTransport(); 

Perhaps you also missed a stacktrace in your logcat with the actual cause of the crash. Try searching for your application package in logcat.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文