使用PushPlugin不会为Android构建PhoneGap Build

时间:2015-07-28 10:02:28

标签: android cordova phonegap-build visual-studio-2015 phonegap-pushplugin

我们有一个PhoneGap应用,在我们添加PushPlugin后拒绝构建。

特别是在使用PhoneGap Build时,我们收到错误:

BUILD FAILED
/home/ec2-user/android-sdk/tools/ant/build.xml:573: ../../../../../../home/ec2-user/android-sdk/com.android.support:support-v4:+ resolve to a path with no project.properties file for project /project

在将PhoneGap($ npm update -g phonegap)和PhoneGap Android平台($ phonegap platform update android)更新为最新版本后,我们偶尔可以使用Ripple模拟器(在Visual Studio中构建)进行构建。

我们已经包含了这样的插件:

<gap:plugin name="com.phonegap.plugins.pushplugin" /> 

或者,在Visual Studio 2015中构建时:

<vs:plugin name="com.phonegap.plugins.PushPlugin" version="2.5.0" src="https://github.com/phonegap-build/PushPlugin.git" xmlns:vs="http://schemas.microsoft.com/appx/2014/htmlapps" /> 

有人可以建议我们可能出错的地方吗?

修改

我们也尝试在命令行上构建,但即使在安装cordova-plugin-android-support-v4之后,也是如此;

$ cordova plugin add cordova-plugin-android-support-v4
    Fetching plugin "cordova-plugin-android-support-v4" via npm
    npm http GET https://registry.npmjs.org/cordova-plugin-android-support-v4
    npm http 200 https://registry.npmjs.org/cordova-plugin-android-support-v4
    Installing "cordova-plugin-android-support-v4" for android

我们仍然会收到错误:

C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordovaApp1>cordova build android
Running command: cmd "/s /c "C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\build.bat""
ANDROID_HOME=C:\Users\XXX\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files (x86)\java\jdk1.7.0_55
Running: C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordovaApp1\platforms\android\gradlew cdvBuildDebug -b C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordova
dle.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.android.support:support-v4:+.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v4/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v4/
     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.897 secs

C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s /c "C:\Dev\CordovaBlank\BlankCordovaApp1\BlankCordovaApp1\platforms\android\gradlew cdvBuildDebug -b C:\Dev\Cor
latforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (C:\Users\XXX\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

4 个答案:

答案 0 :(得分:4)

NEW Push Plugin released recently. Read this (via the Offical Blog), and get the details:
http://simonmacdonald.blogspot.com/2015/07/phonegap-plugin-push-version-111.html

UPDATE (2015-10-24): According to the Phonegap Build blog of Sept 28, 2015
Android Builds Now Using Gradle By Default.

Ant is still available, and can be force into use - with
<preference name="android-build-tool" value="ant" />

Other related changes occur, including automatic minSdkVersion versioning and validation of 9-patch images. Read the blog post for details.

NOTE: On your original problem, gradle (not officially supported by phonegap) is the problem. Some people have worked around this problem, by forcing ant to run in it's place. To find those other posts, search back 30 days from this post; the subjects are similar to this and included: "Failed to build".

答案 1 :(得分:4)

对于PhoneGap Build,请使用 <svg width="800" height="800"> <path fill="#11cc99" stroke="none"> <animate repeatCount="indefinite" begin="0.00s" dur="1.00s" attributeName="d" from="M0.00,100.00L82.06,42.88 196.19,207.12 114.12,264.19 0.00,100.00 Z" to="M31.00,78.06L113.06,20.94 227.19,185.19 145.12,242.25 31.00,78.06 Z" /> </path> <path fill="#99cc11" stroke="none"> <animate repeatCount="indefinite" begin="0.00s" dur="1.00s" attributeName="d" from="M342.00,100.00C342.81,128.19 333.25,151.31 312.69,170.69 C293.31,191.25 270.19,200.81 242.00,200.00 C213.75,200.81 190.56,191.25 171.25,170.69 C150.69,151.31 141.12,128.19 142.00,100.00 C141.12,71.75 150.69,48.56 171.25,29.25 C190.56,8.69 213.75,-0.88 242.00,0.00 C270.19,-0.88 293.31,8.69 312.69,29.25 C333.25,48.56 342.81,71.75 342.00,100.00 Z" to="M342.00,299.44C342.81,327.62 333.25,350.75 312.69,370.12 C293.31,390.69 270.19,400.25 242.00,399.44 C213.75,400.25 190.56,390.69 171.25,370.12 C150.69,350.75 141.12,327.62 142.00,299.44 C141.12,271.19 150.69,248.00 171.25,228.69 C190.56,208.12 213.75,198.56 242.00,199.44 C270.19,198.56 293.31,208.12 312.69,228.69 C333.25,248.00 342.81,271.19 342.00,299.44 Z" /> </path> </svg>强制它使用较旧的受支持版本。

答案 2 :(得分:1)

尝试删除插件并使用以下命令通过命令行安装:

cordova plugin add com.phonegap.plugins.pushplugin --save

您会注意到该插件将在您的config.xml中显示如下:

<plugin name="com.phonegap.plugins.PushPlugin" spec="^2.2.1" />

但它不会在配置设计器上显示,为此,在插件标签前添加“vs:”:

<vs:plugin name="com.phonegap.plugins.PushPlugin" spec="^2.2.1" />

答案 3 :(得分:0)

试试这个(不是100%的工作,但对我有用)。

在platforms / android / project.properties

中删除此行
  

cordova.system.library.1 = com.android.support:支持-V4:+

如果你使用的是facebook插件(比如我),你可以在下面忽略。

  

cordova插件添加android.support.v4