Ionic v2 Google Maps API Android Build Error:无法访问AbstractSafeParcelable options.compassEnabled(controls.getBoolean(“compass”));

时间:2016-12-08 02:01:17

标签: android google-maps ionic-framework ionic2

我正在尝试使用Ionic docs as seen here实现Google Maps API。

我正在使用完全提供的代码示例,但是我收到以下错误:

BUILD FAILED

Total time: 2.748 secs

Error: /path/to/platforms/android/gradlew: Command failed with exit code 1 Error output:
/path/to/platforms/android/src/plugin/google/maps/GoogleMaps.java:479: error: cannot access AbstractSafeParcelable
        options.compassEnabled(controls.getBoolean("compass"));
               ^
  class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details

有没有人见过/解决了这个问题?

1 个答案:

答案 0 :(得分:48)

我能够解决这个问题。虽然我发现的许多建议都围绕着安装缺少的存储库(您需要Android支持存储库,库,Play服务和Google存储库),但我已经完成了所有这些工作。缺少的是当我使用此命令添加插件时,project.properties中指定了错误的版本控制:

ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"

在project.properties中,我改变了这个:

cordova.system.library.4=com.google.android.gms:play-services-maps:9.8.0
cordova.system.library.5=com.google.android.gms:play-services-location:9.8.0

对此:

cordova.system.library.4=com.google.android.gms:play-services-maps:+
cordova.system.library.5=com.google.android.gms:play-services-location:+

解决了构建错误。