PhoneGap Build won't build for Android with PushPlugin
Asked Answered
C

4

7

We have a PhoneGap app which refuses to build once we add in PushPlugin.

Specifically when using PhoneGap Build we get the error:

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

We can occasionally get it to build using the Ripple emulator (building in Visual Studio) after updating PhoneGap ($ npm update -g phonegap) and the PhoneGap Android Platform ($ phonegap platform update android) to the latest versions.

We have included the plugin like this:

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

Or, when building in 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" /> 

Can anyone suggest where we might be going wrong?

EDIT:

We’ve also tried building on the command line, but even after installing cordova-plugin-android-support-v4, thus;

$ 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

we still get errors:

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)
Cementite answered 28/7, 2015 at 10:2 Comment(0)
S
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".

Solferino answered 28/7, 2015 at 23:29 Comment(0)
A
4

For PhoneGap Build, use <gap:plugin name="com.phonegap.plugins.pushplugin" version="2.4.0" /> to force it to use the older, supported, version.

Alpaca answered 29/7, 2015 at 8:35 Comment(0)
L
1

Try removing the plugin and install it via command line using this command:

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

You will notice the plugin will show in your config.xml like this:

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

but it won't show on the config designer, for that to happen, add "vs:" in front of the plugin tag:

<vs:plugin name="com.phonegap.plugins.PushPlugin" spec="^2.2.1" />
Littlefield answered 7/8, 2015 at 23:52 Comment(0)
D
0

Try this (not 100% work, but work for me).

remove this line in platforms/android/project.properties

cordova.system.library.1=com.android.support:support-v4:+

if you are using facebook plugin (like me), you can ignore below.

cordova plugin add android.support.v4

Dahlgren answered 21/8, 2015 at 10:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.