我们有一个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
(和PhoneGapAndroid平台($ 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:DevCordovaBlankBlankCordovaApp1BlankCordovaApp1>cordova build android
Running command: cmd "/s /c "C:DevCordovaBlankBlankCordovaApp1BlankCordovaApp1platformsandroidcordovabuild.bat""
ANDROID_HOME=C:UsersXXXAppDataLocalAndroidsdk
JAVA_HOME=C:Program Files (x86)javajdk1.7.0_55
Running: C:DevCordovaBlankBlankCordovaApp1BlankCordovaApp1platformsandroidgradlew cdvBuildDebug -b C:DevCordovaBlankBlankCordovaApp1BlankCordova
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:DevCordovaBlankBlankCordovaApp1BlankCordovaApp1platformsandroidcordovanode_modulesqq.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:DevCordovaBlankBlankCordovaApp1BlankCordovaApp1platformsandroidgradlew cdvBuildDebug -b C:DevCor
latformsandroidbuild.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:UsersXXXAppDataRoamingnpmnode_modulescordovanode_modulescordova-libsrccordovasuperspawn.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)
最近发布的新推送插件。阅读本文(通过Offical博客(,了解详细信息:
http://simonmacdonald.blogspot.com/2015/07/phonegap-plugin-push-version-111.html
更新(2015-10-24(:根据2015年9月28日的Phonegap Build博客
Android构建现在默认使用渐变。
Ant
仍然可用,可以强制使用-与<preference name="android-build-tool" value="ant" />
一起使用
发生其他相关更改,包括自动minSdkVersion版本控制和9补丁图像验证。阅读博客文章了解详细信息。
注意:
对于您最初的问题,gradle(不受phonegap的官方支持(是问题所在。一些人已经解决了这个问题,迫使ant
在它的位置上运行。要查找其他帖子,请从该帖子向后搜索30天;主题与此类似,包括:"构建失败">
对于PhoneGap构建,使用<gap:plugin name="com.phonegap.plugins.pushplugin" version="2.4.0" />
以强制其使用较旧的、受支持的版本。
尝试删除插件并使用以下命令通过命令行安装:
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" />
试试这个(不是100%有效,但对我有效(。
删除platforms/android/project.properties 中的此行
cordova.system.library.1=com.android.support:support-v4:+
如果你正在使用facebook插件(像我一样(,你可以忽略下面的内容。
cordova插件添加android.support.v4