简体   繁体   English

科尔多瓦无法在android上构建(GCM依赖)

[英]Cordova fails to build on android (GCM dependency)

I have already installed the latest Support Repository package for Android. 我已经安装了最新的Android支持库软件包。

However I cannot compile my new app with ionic/cordova (first build), and I get the following error: 但是我无法使用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$

This is my plugins list: 这是我的插件列表:

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$

How can I solve the problem? 我该如何解决这个问题?

In my case, this message was because of missing packages in the Android SDK, so it was required to install some packages via the Android SDK Manager. 在我的情况下,此消息是因为Android SDK中缺少软件包,因此需要通过Android SDK Manager安装一些软件包。

android # To open the SDK manager

Look for: 寻找:

Extras -> Google play services
Extras -> Google repository

And install them. 并安装它们。

I solved this removing and adding the platform again. 我解决了此删除并再次添加平台的问题。

For some reason I still had some dependecies on an old plugin I uninstalled. 由于某些原因,我仍然对卸载的旧插件有一些依赖。

According to the documentation here you need to configure the gradle build system (File: build.gradle) to install the gcm plugin functionality. 根据此处文档,您需要配置gradle构建系统(文件:build.gradle)以安装gcm插件功能。

eg: 例如:

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

Attention: By using cordova the build.gradle file is automatically generated. 注意:通过使用cordova,将自动生成build.gradle文件。 That means that your additions will be lost every time you call cordova / ionic build 这意味着您每次拨打cordova / ionic build时,添加的内容都会丢失

The cordova team advices to generate a build-extras.gradle file for custom configuration. 科尔多瓦团队建议生成一个build-extras.gradle文件用于自定义配置。

However, for me it is unclear how these files are merged :-( which leads to errors like that one you are facing. 但是,对我而言,目前尚不清楚这些文件如何合并:-(会导致出现您所面临的错误。

Please read my consideration here to work around this problem. 在此处阅读我的考虑事项,以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM