我在www / config.xml中将minSdkVersion设置为8:
<preference name="android-minSdkVersion" value="8" />
<preference name="android-installLocation" value="auto" />
当我运行“phonegap local build android”时,会生成以下文件:
find /Users/alain/Documents/projects/pg33_3/platforms/android -type d \( -name RCS -o -name CVS -o -name .svn -o -name SCCS \) -prune -o -type f \! -name \*\~ \! -name \*\,v \! -name s.\* \! -name .\#\* -print0 | xargs -0 grep -n -e minSdkVersion /dev/null
/Users/alain/Documents/projects/pg33_3/platforms/android/AndroidManifest.xml:13: <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
/Users/alain/Documents/projects/pg33_3/platforms/android/assets/www/config.xml:26: <preference name="android-minSdkVersion" value="8" />
/Users/alain/Documents/projects/pg33_3/platforms/android/bin/AndroidManifest.xml:13: <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />/Users/alain/Documents/projects/pg33_3/platforms/android/CordovaLib/AndroidManifest.xml:22: <uses-sdk android:minSdkVersion="8" />
/Users/alain/Documents/projects/pg33_3/platforms/android/CordovaLib/bin/AndroidManifest.xml:22: <uses-sdk android:minSdkVersion="8" />
/Users/alain/Documents/projects/pg33_3/platforms/android/res/xml/config.xml:53: <preference name="android-minSdkVersion" value="8" />
那么为什么它会在AndroidManifest.xml和bin / AndroidManifest.xml中突然变成minSdkVersion = 10?
这是我的config.xml文件:
<?xml version='1.0' encoding='utf-8'?>
<widget id="it.myapp.MyApp" version="1.5.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>MyApp</name>
<description>
My App
</description>
<author email="contact@myapp.it" href="http://myapp.it">
MyApp Team
</author>
<feature name="http://api.phonegap.com/1.0/device" />
<preference name="permissions" value="none" />
<preference name="orientation" value="portrait" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="8" />
<preference name="android-installLocation" value="auto" />
<icon src="icon.png" />
<icon gap:density="ldpi" gap:platform="android" src="res/icon/android/icon-36-ldpi.png" />
<icon gap:density="mdpi" gap:platform="android" src="res/icon/android/icon-48-mdpi.png" />
<icon gap:density="hdpi" gap:platform="android" src="res/icon/android/icon-72-hdpi.png" />
<icon gap:density="xhdpi" gap:platform="android" src="res/icon/android/icon-96-xhdpi.png" />
<icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" />
<icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
<icon gap:platform="webos" src="res/icon/webos/icon-64.png" />
<icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" />
<icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173.png" />
<gap:splash gap:density="ldpi" gap:platform="android" src="res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:density="mdpi" gap:platform="android" src="res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:density="hdpi" gap:platform="android" src="res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:density="xhdpi" gap:platform="android" src="res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" />
<gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
<gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<access origin="http://127.0.0.1*" />
</widget>
答案 0 :(得分:1)
不幸的是,似乎config.xml中的许多设置仅由Phonegap Build服务使用,并在添加本地平台时被忽略。
我遇到了同样的问题,我发现的唯一解决方案是创建AndroidManifest.xml的副本并对其进行更改 - 然后在.cordova/hooks
文件夹中添加一个钩子来复制您的自定义文件并覆盖cordova提供的默认值。
从长远来看,您可能需要这样做,因为您想要自定义未在phonegap config.xml文件中表示的Android设置。
答案 1 :(得分:0)
您可以编写一些代码进行调整,并将其放入钩子中(如其他答案所述)。
这是一个Ruby-snippet,可以让你走上正确的轨道(当然也可以使用JS或其他语言)。
file_path = root.join("platforms/android/AndroidManifest.xml")
doc = Nokogiri::XML(open(file_path))
# set correct platform requirements
node = doc.css('uses-sdk').first
node['android:minSdkVersion'] = '16'
doc.write_to(File.open(file_path, 'w'))