在Android Studio中找不到LatLng导入

3

当我尝试在我的代码中使用LatLng类时,没有可用的导入。有人能解决这个问题吗?我已经通过SDK管理器安装了Google Play服务模块。

3个回答

5

它可以在以下地方找到:

compile 'com.google.android.gms:play-services-maps:9.6.0'

你可以用最新的版本替换它。


5

LatLng位于com.google.android.gms.maps.model包中,如果您在gradle依赖项中添加implementation 'com.google.android.gms:play-services-maps:15.0.1',则可以使用它。


未能找到:com.google.android.gms:play-services-location:9.2.0 - ShanWave007
@ShanWave007请将 classpath 'com.google.gms:google-services:3.0.0' 添加到build.gradle(project)的buildscript依赖项中,并将 apply plugin: 'com.google.gms.google-services'添加到build.gradle(app)底部 - Tim
无法加载类'com.google.gson.JsonObject'。 - ShanWave007
请忽略与此问题无关的内容。只需谷歌搜索如何导入gson。 - Tim

2
将此内容包含在您的应用程序build.gradle文件中。
 apply plugin: 'com.android.application'

...

dependencies {
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
}

了解更多信息,请查看developers.google.com


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接