【问题标题】:Adding PlaceAutocompleteFragment to an activity throws error将 PlaceAutocompleteFragment 添加到活动会引发错误
【发布时间】:2016-05-30 04:07:32
【问题描述】:

我想在我的应用程序中实现 PlaceAutocompleteFragment based on the docs, 但是当我添加这个 sn-p 时

<fragment
  android:id="@+id/place_autocomplete_fragment"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
  />

最后一行抛出“无法解析符号‘PlaceAutocompleteFragment’。”这是为什么呢?

【问题讨论】:

  • 检查这个实现truiton.com/2015/04/…
  • 你添加compile 'com.google.android.gms:play-services-location:8.4.0'了吗?

标签: android autocomplete


【解决方案1】:

添加这个

implementation 'com.google.android.gms:play-services-places:11.6.0'

【讨论】:

    【解决方案2】:

    编译器找不到该类。您必须通过在 build.gradle 文件中添加以下代码 sn-p 来导入该类。

    dependencies {
        compile 'com.google.android.gms:play-services-places:11.0.4'
    }
    

    【讨论】:

      【解决方案3】:

      无法解析符号 PlaceAutocompleteFragment。

      编译器找不到类。这意味着该类未正确导入、名称拼写错误或该类根本不存在。

      添加这个

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

      终于

      dependencies {
      compile 'com.google.android.gms:play-services-location:8.4.0'
                    }
      

      您可以访问How to Implement PlaceAutocompleteFragment and PlaceAutocompleteActivity to get Place details

      【讨论】:

      • 请给我反馈。
      • 就是这样。我只是删除了我的旧播放服务版本,并用您现在提供的版本替换它,一切都很好。我很感激,我希望 Google 改进他们准备文档的方式。
      • @The_Martian 继续前进。
      猜你喜欢
      • 2016-08-28
      • 2016-08-14
      • 1970-01-01
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-16
      相关资源
      最近更新 更多