Java 导入无法解析:import com.google.android.maps.*;
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3963490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
import cannot be resolved: import com.google.android.maps.*;
提问by coder
I was successfully using google maps in my application but then needed to change the Android SDK version from 1.5 to 2.0. Now the import for Google maps can't be resolved.
我在我的应用程序中成功使用了谷歌地图,但随后需要将 Android SDK 版本从 1.5 更改为 2.0。现在无法解决 Google 地图的导入问题。
采纳答案by Yoni Samlan
Make sure you have
确保你有
<uses-library
android:name="com.google.android.maps" />
in your application manifest, and that you've downloaded not just the 2.0 SDK but the 2.0-with-google-APIs SDK. Then set your project's properties in Eclipse to check off the Google APIs version of the SDK you want. Then try to clean your build (Project-> Clean in eclipse; "ant clean" from the command line).
在您的应用程序清单中,并且您不仅下载了 2.0 SDK,还下载了 2.0-with-google-APIs SDK。然后在 Eclipse 中设置项目的属性以检查所需 SDK 的 Google API 版本。然后尝试清理您的构建(项目-> Eclipse 中的清理;命令行中的“ant clean”)。
回答by sumit pandey
1.Install all google API's using sdk manager.
1. 使用 sdk 管理器安装所有 google API。
2.In your manifest,under application element add
2.在您的清单中,在应用程序元素下添加
<uses-library android:name="com.google.android.maps" />
3.You have to include jar file for maps also.. Right click on your project and go to build path and then add external archives. locate your sdk. android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
3.您还必须包含地图的 jar 文件。右键单击您的项目并转到构建路径,然后添加外部档案。找到你的sdk。android-sdk-windows\add-ons\addon_google_apis_google_inc_8\libs\maps
回答by jpCoder411
adding google-play-services.jar to my project's path solved my problem.
将 google-play-services.jar 添加到我的项目路径解决了我的问题。
right click project->properties->java build path-> libraries tab -> add external jar
右键项目->属性->java构建路径->库选项卡->添加外部jar
browse to android-sdk folder->extras\google\google-play-services\libproject\google-play-services_lib\libs\
浏览到 android-sdk 文件夹->extras\google\google-play-services\libproject\google-play-services_lib\libs\
If you don't have google-play-services folder then you need to close eclipse and open up the SDK manager separately and download google-play.
如果您没有 google-play-services 文件夹,那么您需要关闭 eclipse 并单独打开 SDK 管理器并下载 google-play。
If you already downloaded google-play and still don't see your google-play-services folder, then you need to search for it....chances are that you have multiple android sdks installed....
如果您已经下载了 google-play 并且仍然没有看到您的 google-play-services 文件夹,那么您需要搜索它....您可能安装了多个 android sdks....
回答by kmne68
You may also need to add google-play-services_lib to the project's list of libraries. Doing so resolved this issue for me.
您可能还需要将 google-play-services_lib 添加到项目的库列表中。这样做为我解决了这个问题。
Right-click project->properties->Android
右键项目->属性->Android
Click the 'Add...' button found to the right of the Library Reference/Project table.
单击位于库参考/项目表右侧的“添加...”按钮。
If you have downloaded the Google Play Services Library with the SDK Manager, you should see the library as a choice in the Project Selection box that pops up when you press the Add button.
如果您已使用 SDK 管理器下载了 Google Play 服务库,您应该会在按下“添加”按钮时弹出的“项目选择”框中看到该库作为选项。
If you have not downloaded Google Play Services follow the instructions here: http://developer.android.com/google/play-services/setup.html
如果您尚未下载 Google Play 服务,请按照此处的说明操作:http: //developer.android.com/google/play-services/setup.html
回答by Ricardus
Doing right-click Properties->Android and selecting a Target Name Google APIsinstead of Android x.x fixed the problem for me.
右键单击 Properties->Android 并选择 Target Name Google APIs而不是 Android xx 为我解决了这个问题。
回答by Alekh
Add compile 'com.google.maps.android:android-maps-utils:0.5+'
添加编译 'com.google.maps.android:android-maps-utils:0.5+'
in dependency section of your build.gradle
在 build.gradle 的依赖部分