This is a phonegap 3.5 / cordova 3 android app. In www/config.xml I have:
这是一个phonegap 3.5 / cordova 3 android应用程序。在www / config.xml中,我有:
<preference name="android-minSdkVersion" value="19">
<preference name="android-targetSdkVersion" value="19">
However, when I build it, it creates an AndroidManifest.xml with:
但是,当我构建它时,它会创建一个AndroidManifest.xml:
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
The result is that people with SDK versions below 19 can install my app from the store. Where is it getting that 10 from and how can I change it? Due to weirdness with Viewport, my app's behavior is suspect on OSes below 4.4 and I am already getting 1-star reviews from 4.2.2 users.
结果是SDK版本低于19的人可以从商店安装我的应用程序。从哪里获得10,我该如何改变它?由于Viewport的怪异,我的应用程序的行为在4.4以下的操作系统上是可疑的,我已经从4.2.2用户获得一星评价。
5 个解决方案
#1
49
With older version of cordova CLI, I used to modify manually AndroidManifest.xml
to change a few settings (launch mode, minsdk...) like you do in your answer.
使用较旧版本的cordova CLI,我曾经手动修改AndroidManifest.xml以更改一些设置(启动模式,minsdk ...),就像在答案中一样。
And with Cordova 3.5.something things started to go wrong, and some changes were lost each time I built the project.
随着Cordova 3.5的出现,事情开始出现问题,每次构建项目时都会丢失一些更改。
Now I added those lines in config.xml
and the settings are updated automatically :
现在我在config.xml中添加了这些行,并且设置会自动更新:
<platform name="android">
<preference name="AndroidLaunchMode" value="singleTop"/>
<preference name="android-minSdkVersion" value="14" />
<icon src="res/android/xhdpi.png" />
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
The advantage is that I can now delete the android platform and recreate it without loosing any setting.
优点是我现在可以删除android平台并重新创建它而不会丢失任何设置。
As Phonegap is being updated to be inline with cordova, preferences in config.xml
should work with the new version, and maybe you will see your manual updated be lost like it happened to me...
由于Phonegap正在更新为与cordova内联,config.xml中的首选项应该与新版本一起使用,也许您会看到您的手册更新丢失,就像它发生在我身上一样......
#2
22
STEP 1) yourapp/config.xml file <platform name="android">
tags add two preference
步骤1)yourapp / config.xml文件
<platform name="android">
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="19" />
</platform>
STEP 2) cordova platform rm android
run cmd code
STEP 2)cordova平台rm android运行cmd代码
STEP 3) cordova platform add android
run cmd code Check your AndroidManifest.xml file if look like below
步骤3)cordova平台添加android运行cmd代码检查您的AndroidManifest.xml文件,如下所示
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
every thing is OKAY :)
一切正常 :)
#3
21
Edit and improved answer:
编辑和改进答案:
To answer this, it's better to begin with Build version, or API Level. API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.
要回答这个问题,最好从Build版本或API Level开始。 API Level是一个整数值,用于唯一标识Android平台版本提供的框架API修订版。
API Level 8 == android Platform 2.3(ginger bread)
API Level 17 == android Platform 4.2(jelly bean)
To see complete comparison of APILevel and its AndroidPlatform check here
要查看APILevel及其AndroidPlatform的完整比较,请点击此处
targetSdk is to be used by phonegap only. This tell phonegap to use certain APILevel to build this app. This does not meant to limit any user from downloading your app. It is more like to say, "The app is optimized for this APILevel". example
targetSdk仅供phonegap使用。这告诉phonegap使用某些APILevel来构建这个应用程序。这并不意味着限制任何用户下载您的应用程序。更像是说,“该应用程序针对此APILevel进行了优化”。例
<preference name="android-targetSdkVersion" value="17"/> //android 4.2
This app is build(optimised) using APILevel 17 (which is jellyBean or androidPlatform4.2)
这个应用程序使用APILevel 17(即jellyBean或androidPlatform4.2)构建(优化)
minSdk on the other hand, limit the user/device. minSdk is the minimum requirement of Sdk for user/device. Any device with APIlevel less than APILevel used by minSdk, won't be able to download this app. example:
另一方面,minSdk限制用户/设备。 minSdk是用户/设备的Sdk的最低要求。任何API等级低于minSdk使用的APILevel的设备都无法下载此应用程序。例:
<preference name="android-minSdkVersion" value="11"/> //android 3.0
to download this app, the device has to at least run on android 3.0 (APILevel 11)
要下载这个应用程序,该设备必须至少运行Android 3.0(APILevel 11)
Finally, when used together:
最后,当一起使用时:
<preference name="android-minSdkVersion" value="11"/> //android 3.0
<preference name="android-targetSdkVersion" value="17"/> //android 4.2
This statement means that this app is optimized for android4.2, with minimum requirement of android 3.0
这句话意味着这个应用程序针对android4.2进行了优化,最低要求是android 3.0
Doc: http://docs.build.phonegap.com/en_US/configuring_preferences.md.html#Preferences
Doc:http://docs.build.phonegap.com/en_US/configuring_preferences.md.html#Preferences
#4
2
For anyone getting here looking for a way to set a specific target version, I found this: I just had the same problem. I had to change the target:
对于任何到这里寻找设置特定目标版本的方法的人,我发现了这一点:我遇到了同样的问题。我不得不改变目标:
Project target.
target=android-22 This should be done in two files:
target = android-22这应该在两个文件中完成:
myApp/platforms/android/project.properties myApp/platforms/android/CordovaLib/project.properties
myApp / platforms / android / project.properties myApp / platforms / android / CordovaLib / project.properties
Also the manifest should be updated:
清单应该更新:
From Sebastian answer placed here: Cordova : [Error: Please install Android target: "android-21"
来自塞巴斯蒂安的回答放在这里:科尔多瓦:[错误:请安装Android目标:“android-21”
#5
0
I was able to fix this by manually editing platforms/android/AndroidManifest.xml:
我能够通过手动编辑platforms / android / AndroidManifest.xml来解决这个问题:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
The Phonegap documentation seems to imply that this file should inherit the value of the android-minSdkVersion preference, but it must be changed manually. The android-minSdkVersion preference doesn't seem to do anything as far as I can tell.
Phonegap文档似乎暗示该文件应该继承android-minSdkVersion首选项的值,但必须手动更改。就我所知,android-minSdkVersion首选项似乎没有做任何事情。
#1
49
With older version of cordova CLI, I used to modify manually AndroidManifest.xml
to change a few settings (launch mode, minsdk...) like you do in your answer.
使用较旧版本的cordova CLI,我曾经手动修改AndroidManifest.xml以更改一些设置(启动模式,minsdk ...),就像在答案中一样。
And with Cordova 3.5.something things started to go wrong, and some changes were lost each time I built the project.
随着Cordova 3.5的出现,事情开始出现问题,每次构建项目时都会丢失一些更改。
Now I added those lines in config.xml
and the settings are updated automatically :
现在我在config.xml中添加了这些行,并且设置会自动更新:
<platform name="android">
<preference name="AndroidLaunchMode" value="singleTop"/>
<preference name="android-minSdkVersion" value="14" />
<icon src="res/android/xhdpi.png" />
<icon src="res/android/ldpi.png" density="ldpi" />
<icon src="res/android/mdpi.png" density="mdpi" />
<icon src="res/android/hdpi.png" density="hdpi" />
<icon src="res/android/xhdpi.png" density="xhdpi" />
</platform>
The advantage is that I can now delete the android platform and recreate it without loosing any setting.
优点是我现在可以删除android平台并重新创建它而不会丢失任何设置。
As Phonegap is being updated to be inline with cordova, preferences in config.xml
should work with the new version, and maybe you will see your manual updated be lost like it happened to me...
由于Phonegap正在更新为与cordova内联,config.xml中的首选项应该与新版本一起使用,也许您会看到您的手册更新丢失,就像它发生在我身上一样......
#2
22
STEP 1) yourapp/config.xml file <platform name="android">
tags add two preference
步骤1)yourapp / config.xml文件
<platform name="android">
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value="19" />
</platform>
STEP 2) cordova platform rm android
run cmd code
STEP 2)cordova平台rm android运行cmd代码
STEP 3) cordova platform add android
run cmd code Check your AndroidManifest.xml file if look like below
步骤3)cordova平台添加android运行cmd代码检查您的AndroidManifest.xml文件,如下所示
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
every thing is OKAY :)
一切正常 :)
#3
21
Edit and improved answer:
编辑和改进答案:
To answer this, it's better to begin with Build version, or API Level. API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.
要回答这个问题,最好从Build版本或API Level开始。 API Level是一个整数值,用于唯一标识Android平台版本提供的框架API修订版。
API Level 8 == android Platform 2.3(ginger bread)
API Level 17 == android Platform 4.2(jelly bean)
To see complete comparison of APILevel and its AndroidPlatform check here
要查看APILevel及其AndroidPlatform的完整比较,请点击此处
targetSdk is to be used by phonegap only. This tell phonegap to use certain APILevel to build this app. This does not meant to limit any user from downloading your app. It is more like to say, "The app is optimized for this APILevel". example
targetSdk仅供phonegap使用。这告诉phonegap使用某些APILevel来构建这个应用程序。这并不意味着限制任何用户下载您的应用程序。更像是说,“该应用程序针对此APILevel进行了优化”。例
<preference name="android-targetSdkVersion" value="17"/> //android 4.2
This app is build(optimised) using APILevel 17 (which is jellyBean or androidPlatform4.2)
这个应用程序使用APILevel 17(即jellyBean或androidPlatform4.2)构建(优化)
minSdk on the other hand, limit the user/device. minSdk is the minimum requirement of Sdk for user/device. Any device with APIlevel less than APILevel used by minSdk, won't be able to download this app. example:
另一方面,minSdk限制用户/设备。 minSdk是用户/设备的Sdk的最低要求。任何API等级低于minSdk使用的APILevel的设备都无法下载此应用程序。例:
<preference name="android-minSdkVersion" value="11"/> //android 3.0
to download this app, the device has to at least run on android 3.0 (APILevel 11)
要下载这个应用程序,该设备必须至少运行Android 3.0(APILevel 11)
Finally, when used together:
最后,当一起使用时:
<preference name="android-minSdkVersion" value="11"/> //android 3.0
<preference name="android-targetSdkVersion" value="17"/> //android 4.2
This statement means that this app is optimized for android4.2, with minimum requirement of android 3.0
这句话意味着这个应用程序针对android4.2进行了优化,最低要求是android 3.0
Doc: http://docs.build.phonegap.com/en_US/configuring_preferences.md.html#Preferences
Doc:http://docs.build.phonegap.com/en_US/configuring_preferences.md.html#Preferences
#4
2
For anyone getting here looking for a way to set a specific target version, I found this: I just had the same problem. I had to change the target:
对于任何到这里寻找设置特定目标版本的方法的人,我发现了这一点:我遇到了同样的问题。我不得不改变目标:
Project target.
target=android-22 This should be done in two files:
target = android-22这应该在两个文件中完成:
myApp/platforms/android/project.properties myApp/platforms/android/CordovaLib/project.properties
myApp / platforms / android / project.properties myApp / platforms / android / CordovaLib / project.properties
Also the manifest should be updated:
清单应该更新:
From Sebastian answer placed here: Cordova : [Error: Please install Android target: "android-21"
来自塞巴斯蒂安的回答放在这里:科尔多瓦:[错误:请安装Android目标:“android-21”
#5
0
I was able to fix this by manually editing platforms/android/AndroidManifest.xml:
我能够通过手动编辑platforms / android / AndroidManifest.xml来解决这个问题:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
The Phonegap documentation seems to imply that this file should inherit the value of the android-minSdkVersion preference, but it must be changed manually. The android-minSdkVersion preference doesn't seem to do anything as far as I can tell.
Phonegap文档似乎暗示该文件应该继承android-minSdkVersion首选项的值,但必须手动更改。就我所知,android-minSdkVersion首选项似乎没有做任何事情。