【问题标题】:PhoneGap Build won't build for Android with PushPluginPhoneGap Build 不会使用 PushPlugin 为 Android 构建
【发布时间】:2015-07-28 10:02:28
【问题描述】:

我们有一个 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)

【问题讨论】:

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


    【解决方案1】:

    最近发布了新的推送插件。 阅读本文(通过官方博客),了解详情:
    http://simonmacdonald.blogspot.com/2015/07/phonegap-plugin-push-version-111.html

    更新 (2015-10-24): 根据 2015 年 9 月 28 日的 Phonegap Build 博客
    Android Builds Now Using Gradle By Default

    Ant 仍然可用,并且可以强制使用 - 与
    &lt;preference name="android-build-tool" value="ant" /&gt;

    发生其他相关更改,包括自动 minSdkVersion 版本控制9-patch 图像验证。阅读博文了解详情。

    注意: 在您原来的问题上,gradle(phonegap 不正式支持)是问题所在。有些人通过强制ant 在它的位置运行来解决这个问题。要查找其他帖子,请从该帖子向后搜索 30 天;主题与此类似,包括:“构建失败”。

    【讨论】:

      【解决方案2】:

      对于 PhoneGap 构建,使用 &lt;gap:plugin name="com.phonegap.plugins.pushplugin" version="2.4.0" /&gt; 强制它使用受支持的旧版本。

      【讨论】:

        【解决方案3】:

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

        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" />
        

        【讨论】:

          【解决方案4】:

          试试这个(不是 100% 有效,但为我工作)。

          在platforms/android/project.properties中删除这一行

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

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

          cordova 插件添加 android.support.v4

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2014-09-23
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多