我正在制作一个android mapsActivity应用程序,已在控制台中启用Places API并为android映射了sdk。但是places活动在启动后仍然关闭?香港专业教育学院尝试了以下链接中的所有解决方案,但仍然没有帮助..我在这里做错了吗?另外,Places API和Android版Places Sdk有什么区别?它们是相同的并且是不同的版本还是2个不同的Apis?
place picker close immediately after activity start (google places api)
Place Picker automatically closing
对我的依赖:
implementation "com.google.android.gms:play-services-places:16.0.0"
implementation "com.google.android.gms:play-services-location:16.0.0"
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapsactivity">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Logcat:
2019-04-23 16:00:01.933 1823-4421/? I/ActivityManager: START u0 {act=com.google.android.gms.location.places.ui.PICK_PLACE pkg=com.google.android.gms cmp=com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity (has extras)} from uid 10179 and from pid 27592
2019-04-23 16:00:01.938 1823-4421/? E/ActivityTrigger: activityStartTrigger: not whiteListedcom.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity/16089020
2019-04-23 16:00:01.939 1823-4421/? E/ActivityTrigger: activityResumeTrigger: not whiteListedcom.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity/16089020
2019-04-23 16:00:01.960 1823-4421/? E/ActivityTrigger: activityResumeTrigger: not whiteListedcom.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity/16089020
2019-04-23 16:00:01.974 1823-4421/? I/ActivityManager: Start proc 27752:com.google.android.gms.ui/u0a15 for activity com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity
2019-04-23 16:00:02.307 27752-27752/? I/AppCompatDelegate: Failed to instantiate custom view inflater android.support.v7.app.AppCompatViewInflater. Falling back to default.
java.lang.ClassNotFoundException: android.support.v7.app.AppCompatViewInflater
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at afb.a(:com.google.android.gms@16089020@16.0.89 (040406-239467275):5)
at afb.onCreateView(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:779)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:737)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:2144)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2741)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2847)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2138)
at afb.q(:com.google.android.gms@16089020@16.0.89 (040406-239467275):8)
at afb.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):65)
at dvj.setContentView(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at com.google.android.places.ui.placepicker.PlacePickerChimeraActivity.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):19)
at com.google.android.chimera.Activity.publicOnCreate(Unknown Source:0)
at dvo.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):6)
at ppa.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):2)
at android.app.Activity.performCreate(Activity.java:7314)
at android.app.Activity.performCreate(Activity.java:7305)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3056)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7038)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatViewInflater" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/data/app/com.google.android.gms-uUjbB6k4icCk-HzbRi6tpw==/base.apk"],nativeLibraryDirectories=[/data/app/com.google.android.gms-uUjbB6k4icCk-HzbRi6tpw==/lib/arm64, /data/app/com.google.android.gms-uUjbB6k4icCk-HzbRi6tpw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at afb.a(:com.google.android.gms@16089020@16.0.89 (040406-239467275):5)
at afb.onCreateView(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:779)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:737)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:2144)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2741)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2847)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2138)
at afb.q(:com.google.android.gms@16089020@16.0.89 (040406-239467275):8)
at afb.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):65)
at dvj.setContentView(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at com.google.android.places.ui.placepicker.PlacePickerChimeraActivity.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):19)
at com.google.android.chimera.Activity.publicOnCreate(Unknown Source:0)
at dvo.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):6)
at ppa.onCreate(:com.google.android.gms@16089020@16.0.89 (040406-239467275):2)
at android.app.Activity.performCreate(Activity.java:7314)
at android.app.Activity.performCreate(Activity.java:7305)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3056)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7038)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
2019-04-23 16:00:02.894 1823-4421/? V/WindowManager: Changing focus from null to Window{51b1263 u0 com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity}
2019-04-23 16:00:03.078 1823-2068/? I/ActivityManager: Displayed com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity: +1s112ms
2019-04-23 16:00:03.684 3152-5161/? E/Volley: [103] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/placesandroid/v1/placePicker?key=AIzaSyB-PM7l1fJIxvCY6yFItebHa_30u4PmKKM
2019-04-23 16:00:03.690 3152-27601/? E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details.
2019-04-23 16:00:03.691 3152-27601/? E/AsyncOperation: serviceID=65, operation=PlacePickerQuota
OperationException[Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED, resolution=null}]
at bear.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at beaq.a(:com.google.android.gms@16089020@16.0.89 (040406-239467275):5)
at zgb.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):27)
at bgot.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):2)
at rrt.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):32)
at rrt.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):21)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at rxx.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
2019-04-23 16:00:03.692 27752-27752/? E/Places: Place Picker closing due to PLACES_API_ACCESS_NOT_CONFIGURED
2019-04-23 16:00:03.748 1823-3834/? V/WindowManager: Changing focus from Window{51b1263 u0 com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity} to Window{d5594ef u0 com.example.mapsactivity/com.example.mapsactivity.MapsActivity}
2019-04-23 16:00:04.097 3152-5164/? E/Volley: [105] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/placesandroid/v1/search?key=AIzaSyB-PM7l1fJIxvCY6yFItebHa_30u4PmKKM
2019-04-23 16:00:04.100 3152-27601/? E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details.
2019-04-23 16:00:04.100 3152-27601/? E/AsyncOperation: serviceID=65, operation=SearchPlaces
OperationException[Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED, resolution=null}]
at bear.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):1)
at beat.a(:com.google.android.gms@16089020@16.0.89 (040406-239467275):23)
at zgb.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):27)
at bgot.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):2)
at rrt.b(:com.google.android.gms@16089020@16.0.89 (040406-239467275):32)
at rrt.run(:com.google.android.gms@16089020@16.0.89 (040406-239467275):18)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at rxx.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
答案 0 :(得分:0)
针对仍然面临此问题的人们。我的问题是钥匙。我的帐户已启用api,但我的密钥未启用。我做了一个新钥匙,现在可以正常使用了。