【问题标题】:Importing Eclipse project to Android Studio: Google Maps API将 Eclipse 项目导入 Android Studio:Google Maps API
【发布时间】:2014-02-07 09:12:24
【问题描述】:

我在尝试将我的项目从 Eclipse 导入 Android Studio 时遇到了一些问题。它给了我诸如error: package com.google.android.maps does not existerror: cannot find symbol class MapActivity 之类的错误。

我已尝试关注数百篇关于此问题的帖子,但似乎没有任何效果。 我尝试将它放入我的 build.gradle:compile 'com.google.android.gms:play-services:3.1.36' 并且不起作用(我也尝试过使用最新版本)。 这是弃用的问题吗,因为它似乎没有抱怨 SitesOverlay?

我已尝试更改我的 api 密钥,但我认为这不会产生这些错误。 我也看过关于模块等的帖子,但后来我从一些帖子中读到这不是必需的。我还确保我下载了所有正确的 sdk 内容,包括所有附加内容等。

我已经参考过的许多网站中的一些:

Android Studio 0.2 App that use Google Maps - Gradle modify

com.google.android.maps does not exist strange error

Package com.google.android.maps does not exist (IntelliJ)

【问题讨论】:

  • 如果您遇到 IDE 无法解析符号的问题,请查看 stackoverflow.com/questions/21100688/… 看看它对您有多大帮助
  • 我会尝试,但即使在多次重新导入后我也无法解决此问题。感谢您的建议。
  • 在 0.4.2 中存在一个问题,即缓存坏的东西并且重新导入没有帮助。在我的回答中,我让你吹走 .iml 和 .idea/ 文件并重新导入。看看这是否有帮助,如果您仍然遇到问题,请使用更多详细信息修改您的问题,包括您的 build.gradle 文件以及您所看到的确切错误的更多详细信息。
  • 好的,谢谢。老实说,我不明白为什么这不像 eclipse 中那样简单的导入。
  • 尚未实施。在我们宣布它为 1.0 之前,我们还有很长的路要走。

标签: java android eclipse android-studio


【解决方案1】:

我的 build.gradle 文件包含以下内容:

dependencies {
compile 'com.android.support:appcompat-v7:+'
compile ('com.android.support:appcompat-v7:+')
compile ('com.google.android.gms:play-services:4.0.30')
}

下面,我的地图活动导入了这些:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
import com.google.android.gms.common.GooglePlayServicesClient.OnConnectionFailedListener;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

所以我认为这只是更新您导入的内容以符合新地图服务的 CAS。具体来说,您在应该使用 com.google.android.gms.maps 时使用的是 com.google.android.maps等等

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    相关资源
    最近更新 更多