且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

导入 com.google.android.gms 无法解析

更新时间:2021-07-17 22:45:55

我检查了 Google API 作为项目构建目标.

I checked off Google API as project build target.

这无关紧要,因为这适用于 Maps V1,而您正在尝试使用 Maps V2.

That is irrelevant, as that is for Maps V1, and you are trying to use Maps V2.

我通过右键单击我的项目包含地图的 .jar 文件,转到构建路径并添加外部存档以将其定位在我的 SDK 中:android-sdk-windowsadd-onsaddon_google_apis_google_inc_8libsmaps

I included .jar file for maps by right-clicking on my project, went to build path and added external archive locating it in my SDK: android-sdk-windowsadd-onsaddon_google_apis_google_inc_8libsmaps

这是双重错误.

首先,切勿在 Android 项目中手动修改构建路径.如果您这样做,充其量会在运行时崩溃,因为您认为放入项目(通过手动构建路径更改)的 JAR 不在您的 APK 中.对于普通的第三方JAR,把它放在你项目的libs/目录下,它会自动将它添加到你的构建路径中将它的内容添加到你的APK文件中.

First, never manually modify the build path in an Android project. If you are doing that, at best, you will crash at runtime, because the JAR you think you put in your project (via the manual build path change) is not in your APK. For an ordinary third-party JAR, put it in the libs/ directory of your project, which will add it to your build path automatically and add its contents to your APK file.

但是,Maps V2 不是 JAR.它是一个包含 JAR 的 Android 库项目.您需要整个库项目.

However, Maps V2 is not a JAR. It is an Android library project that contains a JAR. You need the whole library project.

您需要将 android-sdk-windowsadd-onsaddon_google_apis_google_inc_8 项目导入 Eclipse,然后将其添加到您的应用程序 作为对 Android 库项目的引用.

You need to import the android-sdk-windowsadd-onsaddon_google_apis_google_inc_8 project into Eclipse, then add it to your app as a reference to an Android library project.