【问题标题】:Cordova fails to build on android (GCM dependency)Cordova 无法在 android 上构建(GCM 依赖项)
【发布时间】:2016-02-02 04:36:56
【问题描述】:

我已经为 Android 安装了最新的 Support Repository 包。

但是,我无法使用 ionic/cordova(首次构建)编译我的新应用,并且出现以下错误:

TR: ~/Documents/bitron/B-See tommaso$ ionic run --device android
Running command: /Users/webdev1/Documents/bitron/B-See/hooks/after_prepare/010_add_platform_class.js /Users/webdev1/Documents/bitron/B-See
add to body class: platform-android
Running command: /Users/webdev1/Documents/bitron/B-See/platforms/android/cordova/run --device
ANDROID_HOME=/usr/share/java/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Running: /Users/webdev1/Documents/bitron/B-See/platforms/android/gradlew cdvBuildDebug -b /Users/webdev1/Documents/bitron/B-See/platforms/android/build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.google.android.gms:play-services-gcm:+.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/google/android/gms/play-services-gcm/maven-metadata.xml
         https://repo1.maven.org/maven2/com/google/android/gms/play-services-gcm/
         file:/usr/share/java/android-sdk-macosx/extras/android/m2repository/com/google/android/gms/play-services-gcm/maven-metadata.xml
         file:/usr/share/java/android-sdk-macosx/extras/android/m2repository/com/google/android/gms/play-services-gcm/
     Required by:
         :android:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.769 secs

/Users/webdev1/Documents/bitron/B-See/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                    ^
Error code 1 for command: /Users/webdev1/Documents/bitron/B-See/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/webdev1/Documents/bitron/B-See/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true
ERROR running one or more of the platforms: Error: /Users/webdev1/Documents/bitron/B-See/platforms/android/cordova/run: Command failed with exit code 1
You may not have the required environment or OS to run this project
TR: ~/Documents/bitron/B-See tommaso$

这是我的插件列表:

TR: ~/Documents/bitron/B-See tommaso$ ionic plugin list
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-dialogs 1.1.1 "Notification"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
ionic-plugin-keyboard 1.0.7 "Keyboard"
nl.x-services.plugins.toast 2.0.4 "Toast"
TR: ~/Documents/bitron/B-See tommaso$

我该如何解决这个问题?

【问题讨论】:

  • 你的科尔多瓦版本是什么? cordova -v你能把你的build-extras.gradle的相关部分贴出来吗?
  • 而且我没有名为“build-extras.gradle”的文件:(
  • 这很奇怪,因为您还没有安装任何可以搜索com.google.android.gms:play-services-gcm:+..的插件。您是否安装过与推送通知相关的任何东西?
  • 我确实从github.com/phonegap/phonegap-plugin-push 安装了phonegap-plugin-push 但后来我删除了它
  • ionic state reset 应该可以帮助您。但为了将来参考,即使phonegap-plugin-push 也不需要更改任何 gradle 文件。

标签: android cordova gradle google-cloud-messaging ionic


【解决方案1】:

在我的情况下,此消息是由于 Android SDK 中缺少包,因此需要通过 Android SDK 管理器安装一些包。

android # To open the SDK manager

寻找:

Extras -> Google play services
Extras -> Google repository

并安装它们。

【讨论】:

  • 那个正确的遮阳篷,它是关于错过的 android sdk 包。
  • 这应该是答案
  • 嘿,我遇到了同样的问题,我没有安装 sdk 管理器或 android 库,但是在 adobe 网站上进行远程构建,你能指导我解决这个问题吗?
【解决方案2】:

我解决了这个删除和添加平台的问题。

由于某种原因,我仍然对我卸载的旧插件有一些依赖。

【讨论】:

  • 谢谢,这对我来说是正确的答案。我总是忘记这样做 - 我肯定安装了所有正确的 SDK 包,只是一个科尔多瓦打嗝。
  • 让我很困扰的一件事是在使用 git 存储库克隆或切换分支时到处都是插件...您总是需要检查已安装的插件和/或删除-重新安装它们全部。我希望它们只是 npm 软件包并使用 npm install 安装它们...哈哈
【解决方案3】:

根据documentation here需要配置gradle构建系统(文件:build.gradle)来安装gcm插件功能。

例如:

dependencies {
  compile "com.google.android.gms:play-services-gcm:8.1.0"
}

注意:使用 cordova 会自动生成 build.gradle 文件。这意味着您每次调用cordova / ionic build时添加的内容都会丢失

cordova 团队建议为自定义配置生成一个build-extras.gradle 文件。

但是,对我而言,不清楚这些文件是如何合并的 :-( 这会导致您面临的错误。

请阅读我的consideration here 以解决此问题。

【讨论】:

  • 我不明白为什么我的新应用程序(默认模板)甚至无法构建。这意味着每个人在第一次尝试编译新项目时都会遇到此构建错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-09
  • 1970-01-01
  • 1970-01-01
  • 2018-11-09
  • 1970-01-01
  • 1970-01-01
  • 2021-05-28
相关资源
最近更新 更多