我最近一直在使用Android Studio模拟器遇到这个问题,我不知道它出现的原因和原因,因为直到现在我的模拟器和应用程序工作正常。
现在,当我尝试运行我的应用程序(使用Google地图和Google商家信息自动填充功能)时,会显示一条消息,显示未安装Google Play服务。我设法在我的模拟器上安装它,但该应用程序仍然无法正常工作。系统会显示Google地图,但Google商家信息自动填充功能不再有效。
我注意到这是Android开发人员的一个常见问题,经过一些研究后我一直试图调整一些解决方案,但问题仍然存在。
任何人都可以帮我解决这个问题并向我解释为什么会这样吗?是因为某些Android Studio更新?
(错误讯息)
05-20 21:56:52.528: A/GmsApplication(2108): Unable to install secure provider, due to exception:
05-20 21:56:52.528: A/GmsApplication(2108): java.lang.SecurityException: attempting to read gservices without permission: Neither user 10053 nor current process has com.google.android.providers.gsf.permission.READ_GSERVICES.
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ContextImpl.enforce(ContextImpl.java:1914)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1943)
05-20 21:56:52.528: A/GmsApplication(2108): at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:600)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gsf.f.c(SourceFile:107)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gsf.f.a(SourceFile:121)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gsf.f.a(SourceFile:227)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.a.l.a(SourceFile:301)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.a.e.a(SourceFile:219)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.a.d.c(SourceFile:197)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.a.d.d(SourceFile:208)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.security.ProviderInstallerImpl.insertProviderGated(SourceFile:90)
05-20 21:56:52.528: A/GmsApplication(2108): at com.google.android.gms.common.app.GmsApplication.onCreate(SourceFile:84)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4556)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ActivityThread.access$1500(ActivityThread.java:151)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
05-20 21:56:52.528: A/GmsApplication(2108): at android.os.Handler.dispatchMessage(Handler.java:102)
05-20 21:56:52.528: A/GmsApplication(2108): at android.os.Looper.loop(Looper.java:135)
05-20 21:56:52.528: A/GmsApplication(2108): at android.app.ActivityThread.main(ActivityThread.java:5257)
05-20 21:56:52.528: A/GmsApplication(2108): at java.lang.reflect.Method.invoke(Native Method)
05-20 21:56:52.528: A/GmsApplication(2108): at java.lang.reflect.Method.invoke(Method.java:372)
05-20 21:56:52.528: A/GmsApplication(2108): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-20 21:56:52.528: A/GmsApplication(2108): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-20 21:56:52.552: D/AndroidRuntime(2108): Shutting down VM
05-20 21:56:52.560: E/AndroidRuntime(2108): FATAL EXCEPTION: main
05-20 21:56:52.560: E/AndroidRuntime(2108): Process: com.google.android.gms, PID: 2108
05-20 21:56:52.560: E/AndroidRuntime(2108): java.lang.RuntimeException: Unable to start receiver com.google.android.gms.subscribedfeeds.ConfigurationReceiver: java.lang.SecurityException: attempting to read gservices without permission: Neither user 10053 nor current process has com.google.android.providers.gsf.permission.READ_GSERVICES.
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2619)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ActivityThread.access$1700(ActivityThread.java:151)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.os.Handler.dispatchMessage(Handler.java:102)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.os.Looper.loop(Looper.java:135)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ActivityThread.main(ActivityThread.java:5257)
05-20 21:56:52.560: E/AndroidRuntime(2108): at java.lang.reflect.Method.invoke(Native Method)
05-20 21:56:52.560: E/AndroidRuntime(2108): at java.lang.reflect.Method.invoke(Method.java:372)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
05-20 21:56:52.560: E/AndroidRuntime(2108): Caused by: java.lang.SecurityException: attempting to read gservices without permission: Neither user 10053 nor current process has com.google.android.providers.gsf.permission.READ_GSERVICES.
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ContextImpl.enforce(ContextImpl.java:1914)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ContextImpl.enforceCallingOrSelfPermission(ContextImpl.java:1943)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.content.ContextWrapper.enforceCallingOrSelfPermission(ContextWrapper.java:600)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.google.android.gsf.f.c(SourceFile:107)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.google.android.gsf.f.a(SourceFile:121)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.google.android.gsf.f.a(SourceFile:182)
05-20 21:56:52.560: E/AndroidRuntime(2108): at com.google.android.gms.subscribedfeeds.ConfigurationReceiver.onReceive(SourceFile:31)
05-20 21:56:52.560: E/AndroidRuntime(2108): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2612)
05-20 21:56:52.560: E/AndroidRuntime(2108): ... 9 more
答案 0 :(得分:1)
您必须在具有Google API的模拟器上运行该应用,在创建模拟器时它是一个选项。只需使用Google API选择目标,请参见下图:
答案 1 :(得分:0)
确保您的应用安装了Google Play服务。如果您还没有这样做,请在build.gradle
文件中添加以下依赖项:
dependencies {
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:7.3.0'
}
执行此操作后保存更改,然后单击工具栏中的“使用Gradle文件同步项目”。
如果您要访问Google Play服务功能,强烈建议您使用GoogleApiClient课程。要检测设备是否具有适当版本的Google Play服务APK,请实施onConnectionFailed()回调方法。如果由于Google Play APK的版本丢失或过时而导致连接失败。
对于Autocomplete API无效,请检查API_KEY是否也已添加到清单文件中,调用GeoDataApi.getAutocompletePredictions()以字符串形式传递查询以及LatLngBounds。有关更多信息,请参阅以下documentation。