PlacePicker已贬值

时间:2019-06-21 13:18:20

标签: android google-maps kotlin

我遵循了有关使用Android Studio实施Google Maps API的教程,当我发现Place Picker已贬值时,我的进度暂停了。结果,我的应用程序在打开时崩溃。

在本教程中,我已经实现了MapView,缩放功能,中心功能和位置更新请求,并且在实现位置搜索时遇到了问题。

    private fun loadPlacePicker() { //creates new builder for an intent to start the Place Picker UI
        val builder = PlacePicker.IntentBuilder()

        try {
            startActivityForResult(builder.build(this@MapsActivity), PLACE_PICKER_REQUEST)
        } catch (e: GooglePlayServicesRepairableException) {
            e.printStackTrace()
        } catch (e: GooglePlayServicesNotAvailableException) {
            e.printStackTrace()
        }
    }

我相信预期的结果将是实现一个浮动操作栏,该栏可用于搜索位置。在代码上,PlacePicker被删除,并显示一条消息:“'PlacePicker'已弃用。在Java中已弃用”。

显示以下错误,我不知道这意味着什么:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 9675
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MapsActivity}: android.view.InflateException: Binary XML file line #2 in com.example.myapplication:layout/activity_maps: Binary XML file line #2 in com.example.myapplication:layout/activity_maps: Error inflating class android.support.design.widget.CoordinatorLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3121)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:81)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1935)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7116)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925)
     Caused by: android.view.InflateException: Binary XML file line #2 in com.example.myapplication:layout/activity_maps: Binary XML file line #2 in com.example.myapplication:layout/activity_maps: Error inflating class android.support.design.widget.CoordinatorLayout
     Caused by: android.view.InflateException: Binary XML file line #2 in com.example.myapplication:layout/activity_maps: Error inflating class android.support.design.widget.CoordinatorLayout
     Caused by: java.lang.ClassNotFoundException: android.support.design.widget.CoordinatorLayout
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.view.LayoutInflater.createView(LayoutInflater.java:830)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1021)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:976)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:674)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:549)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:496)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.example.myapplication.MapsActivity.onCreate(MapsActivity.kt:153)
        at android.app.Activity.performCreate(Activity.java:7698)
        at android.app.Activity.performCreate(Activity.java:7687)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3257)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:81)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1935)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7116)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925)
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/base.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_resources_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/lib/x86, /system/lib, /system/product/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            ... 26 more
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.example.myapplication-hlq7WMD7jhn1Gt1eYykECw==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:365)
        at dalvik.system.DexFile.<init>(DexFile.java:107)
        at dalvik.system.DexFile.<init>(DexFile.java:80)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:444)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:403)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:126)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:101)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
        at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:861)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:958)
        at android.app.LoadedApk.getResources(LoadedApk.java:1196)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2462)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2454)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6105)
        at android.app.ActivityThread.access$1100(ActivityThread.java:211)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1778)
                ... 6 more

1 个答案:

答案 0 :(得分:0)

基于文档:

  

已于2019年1月29日弃用了Place Picker(Android,iOS)。   此功能将于2019年7月29日关闭,并且不再   在该日期之后可用。要继续将Place Picker与   在整个弃用期限内放置iOS版v.2.7.0的SDK,请勿   禁用iOS版Places SDK。

请注意,只有2019年1月29日之前的Place Picker用户才可以继续使用Place Picker直到2019年7月29日,因为这是因为只有 Places SDK才能使用Place Picker在GCP Console中启用了iOS / Android版 iOS / Android版Places SDK 现在对新用户不可见。现在,新用户将需要启用Places API才能使用其中Place Selecter现在不可用的移动SDK。

Google目前正在对促使用户使用位置选择器的因素进行审查,如果您有兴趣,可以在问题跟踪器中以issue中提到的形式添加答案。