Phonegap Build在构建期间抛出错误。我刚刚将此字符串添加到" config.xml"。
<plugin name="cordova-plugin-mauron85-background-geolocation" source="npm" spec="^2.2.0"/>
这是我的&#34; config.xml&#34;文件。
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>MyApp</name>
<description>
My new app
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-build-tool" value="gradle" />
<plugin name="cordova-plugin-mauron85-background-geolocation" source="npm" spec="^2.2.0"/>
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<platform name="android">
<icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />
<icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />
<icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="www/res/screen/android/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="www/res/screen/android/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="www/res/screen/android/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="www/res/screen/android/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="www/res/screen/android/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="www/res/screen/android/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />
</platform>
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
</widget>
&#13;
这是我的错误日志:
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-mauron85-background-geolocation@^2.2.0" via npm
Installing "cordova-plugin-mauron85-background-geolocation" at "2.2.5" for android
Fetching plugin "cordova-plugin-battery-status@~1.1.1" via npm
Installing "cordova-plugin-battery-status" at "1.1.2" for android
Fetching plugin "cordova-plugin-camera@~2.1.1" via npm
Installing "cordova-plugin-camera" at "2.1.1" for android
Fetching plugin "cordova-plugin-media-capture@~1.2.0" via npm
Installing "cordova-plugin-media-capture" at "1.2.0" for android
Fetching plugin "cordova-plugin-file" via npm
Installing "cordova-plugin-file" at "4.3.1" for android
Fetching plugin "cordova-plugin-compat" via npm
Installing "cordova-plugin-compat" at "1.1.0" for android
The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.
If this is a new application no changes are required.
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Fetching plugin "cordova-plugin-console@~1.0.2" via npm
Installing "cordova-plugin-console" at "1.0.5" for android
Fetching plugin "cordova-plugin-contacts@~2.0.1" via npm
Installing "cordova-plugin-contacts" at "2.0.1" for android
Fetching plugin "cordova-plugin-device@~1.1.1" via npm
Installing "cordova-plugin-device" at "1.1.4" for android
Fetching plugin "cordova-plugin-device-motion@~1.2.0" via npm
Installing "cordova-plugin-device-motion" at "1.2.3" for android
Fetching plugin "cordova-plugin-device-orientation@~1.0.2" via npm
Installing "cordova-plugin-device-orientation" at "1.0.5" for android
Fetching plugin "cordova-plugin-dialogs@~1.2.0" via npm
Installing "cordova-plugin-dialogs" at "1.2.1" for android
Plugin "cordova-plugin-file" already installed on android. Making it top-level.
Fetching plugin "cordova-plugin-file-transfer@~1.5.0" via npm
Installing "cordova-plugin-file-transfer" at "1.5.1" for android
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-geolocation@~2.1.0" via npm
Installing "cordova-plugin-geolocation" at "2.1.0" for android
Fetching plugin "cordova-plugin-globalization@~1.0.3" via npm
Installing "cordova-plugin-globalization" at "1.0.5" for android
Fetching plugin "cordova-plugin-inappbrowser@~1.3.0" via npm
Installing "cordova-plugin-inappbrowser" at "1.3.0" for android
Fetching plugin "cordova-plugin-media@~2.2.0" via npm
Installing "cordova-plugin-media" at "2.2.0" for android
Dependent plugin "cordova-plugin-file" already installed on android.
Fetching plugin "cordova-plugin-network-information@~1.2.0" via npm
Installing "cordova-plugin-network-information" at "1.2.1" for android
Fetching plugin "cordova-plugin-splashscreen@~3.2.1" via npm
Installing "cordova-plugin-splashscreen" at "3.2.2" for android
Fetching plugin "cordova-plugin-statusbar@~2.1.2" via npm
Installing "cordova-plugin-statusbar" at "2.1.3" for android
Fetching plugin "cordova-plugin-vibration@~2.1.0" via npm
Installing "cordova-plugin-vibration" at "2.1.3" for android
Fetching plugin "cordova-plugin-whitelist@~1.2.1" via npm
Installing "cordova-plugin-whitelist" at "1.2.2" for android
This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.
--------------------------------------------------------------------------------
COMPILE OUTPUT
--------------------------------------------------------------------------------
Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugNdk UP-TO-DATE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
:CordovaLib:packageDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:compileDebugAidl
:CordovaLib:generateDebugBuildConfig
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:CordovaLib:processDebugManifest
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processDebugJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:compileReleaseNdk UP-TO-DATE
:CordovaLib:copyReleaseLint UP-TO-DATE
:CordovaLib:mergeReleaseProguardFiles
:CordovaLib:packageReleaseRenderscript UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseRenderscript
:CordovaLib:generateReleaseResValues
:CordovaLib:generateReleaseResources
:CordovaLib:packageReleaseResources
:CordovaLib:compileReleaseAidl
:CordovaLib:generateReleaseBuildConfig
:CordovaLib:mergeReleaseShaders
:CordovaLib:compileReleaseShaders
:CordovaLib:generateReleaseAssets
:CordovaLib:mergeReleaseAssets
:CordovaLib:processReleaseManifest
:CordovaLib:processReleaseResources
:CordovaLib:generateReleaseSources
:CordovaLib:incrementalReleaseJavaCompilationSafeguard
:CordovaLib:compileReleaseJavaWithJavac
:CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processReleaseJavaRes UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForRelease
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
:CordovaLib:mergeReleaseJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease
:CordovaLib:bundleRelease
:prepareComAndroidSupportSupportCompat2510Library
:prepareComAndroidSupportSupportCoreUi2510Library
:prepareComAndroidSupportSupportCoreUtils2510Library
:prepareComAndroidSupportSupportFragment2510Library
:prepareComAndroidSupportSupportMediaCompat2510Library
:prepareComAndroidSupportSupportV42510Library
:prepareComGoogleAndroidGmsPlayServicesBase1001Library
:prepareComGoogleAndroidGmsPlayServicesBasement1001Library
:prepareComGoogleAndroidGmsPlayServicesLocation1001Library
:prepareComGoogleAndroidGmsPlayServicesTasks1001Library
:prepareProjectCordovaLibUnspecifiedDebugLibrary
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugBuildConfig
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:mergeDebugAssets
:generateDebugResValues
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources/project/res/xml/authenticator.xml:5:19-31: AAPT: No resource found that matches the given name (at 'icon' with value '@mipmap/icon').
/project/res/xml/authenticator.xml:6:24-36: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@mipmap/icon').
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/android-sdk/build-tools/24.0.1/aapt'' finished with non-zero exit value 1
* 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: 3.188 secs
Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/project/res/xml/authenticator.xml:5:19-31: AAPT: No resource found that matches the given name (at 'icon' with value '@mipmap/icon').
/project/res/xml/authenticator.xml:6:24-36: AAPT: No resource found that matches the given name (at 'smallIcon' with value '@mipmap/icon').
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/android-sdk/build-tools/24.0.1/aapt'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
at ChildProcess.whenDone (/project/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
&#13;
如何正确配置插件以构建?
答案 0 :(得分:1)
简短回答
将<preference name="phonegap-version" value="cli-6.4.0" />
添加到您的config.xml
长答案
插件includes the Android Support Library并指定版本+
- 即由Google联合推出的最新版本,目前为v41,需要Android API 24 +的编译SDK。
在Cordova / Phonegap项目中,Android编译SDK版本与Cordova Android平台的版本密切相关:
`cordova-android@5.2.1` => API 23
`cordova-android@6.1.0` => API 25
Phonegap根据CLI版本(see here)构建cordova-android
版本,目前默认CLI版本为6.3.0 =&gt; cordova-android@5.2.1
=&gt; Android编译SDK v23。通过指定CLI v6.4.0,cordova-android
平台设置为v6.1.0 =&gt; Android编译SDK v25。因此,这将适用于最新版本的Android支持库。