2014-02-05 55 views
3

我在萬維網/ config.xml中設置的minSdkVersion至8:PhoneGap的3.3和的minSdkVersion = 8變的minSdkVersion = 10

<preference name="android-minSdkVersion" value="8" /> 
<preference name="android-installLocation" value="auto" /> 

當運行 「的PhoneGap本地構建機器人」,生成了以下文件:

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="[email protected]" 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

你能告訴我你的config.xml文件,我應該能夠進一步提供幫助嗎? – keldar

+0

謝謝。我已將它添加到我的問題中。 –

回答

1

遺憾的是,似乎有很多在config.xml中的設置僅用於由的PhoneGap構建服務和增加地方平臺時會被忽略。

我遇到了同樣的問題,我找到的唯一解決方案是創建一個AndroidManifest.xml的副本並對其進行更改 - 然後在.cordova/hooks文件夾中添加一個鉤子以複製您的自定義文件並覆蓋由科爾多瓦提供的默認版本。

無論如何,您可能需要使用此設置,因爲您要自定義Android設置,這些設置在phonegap config.xml文件中未表示。

0

您可以編寫一些代碼來進行調整,並將其放入鉤子(如其他答案所述)。

這是一個Ruby代碼片段,它可以讓你在正確的軌道上(當然也可以使用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'))