我正在尝试提交我的应用程序,并且版本没有按预期出现,总是在Playstore上添加数字8(结果为30203 8 )
我已经尝试删除并添加相同的Android平台。从Android Studio的项目结构中更改版本似乎也无济于事。我应该在哪里查看?
我非常感谢任何建议,提前谢谢
Cordova:6.0.0
Android平台:4.1.1
<?xml version='1.0' encoding='utf-8'?>
<widget id=.. version="3.2.03" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Test</name>
<description>
..bla
</description>
<author email="a@a.com" href="http://www.web.com">
Author
</author>
<content src="index.html" />
<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:*" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-targetSdkVersion" value ="16" />
<preference name="Orientation" value="sensorLandscape" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<!--<preference name="android-hardwareAccelerated" value="false" />
<preference name="android-windowSoftInputMode" value="adjustPan" /> -->
</platform>
</widget>
修改的
为了使修复运行每个构建,我在平台标记下面的config.xml中创建了一个钩子:
...
<platform name="android">
<hook type="before_build" src="scripts/androidVersionFix.js" />
...
在脚本文件夹中,androidVersionFix.js:
#!/usr/bin/env node
/*
----the file creates:-----------
# In <your-project>/platforms/android/gradle.properties
cdvVersionCode=30203
---------------------------------
where 30203 is the android-versionCode from config.xml
*/
var configXml = 'config.xml';
var fs = require('fs');
var exec = require('child_process').exec;
var appVersion = '';
var fileContents = function() {
return "#Android version code fix: In <your-project>/platforms/android/gradle.properties \\n \
cdvVersionCode="+appVersion
};
var command = "sed -n 's/.*android-versionCode=\"\\([^\"]*\\).*/\\1/p' ";
exec(command + configXml, function(e,out,err){
appVersion = out;
console.log('echo creating gradle.properties, app Version: ' + appVersion);
exec('echo "'+fileContents()+'" > ./platforms/android/gradle.properties');
});
答案 0 :(得分:1)
是的,build.gradle
来自其提取的问题,并且不会编辑build.gradle
。做一件事在platform / android中创建gradle.properties文件并将此cdvVersionCode=3.2.03
语句粘贴到gradle.properties
。它应该工作
答案 1 :(得分:1)
这看起来像是cordova 5.0.0及更高版本中尚未解决的错误。这个链接有更多info。在看了platforms \ android文件夹下的build.gradle文件之后,下面的代码似乎正在对版本号进行操作,
if (Boolean.valueOf(cdvBuildMultipleApks)) {
productFlavors {
armv7 {
versionCode defaultConfig.versionCode + 2
ndk {
abiFilters "armeabi-v7a", ""
}
}
x86 {
versionCode defaultConfig.versionCode + 4
ndk {
abiFilters "x86", ""
}
}
all {
ndk {
abiFilters "all", ""
}
}
}
} else if (!cdvVersionCode) {
def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
// Vary versionCode by the two most common API levels:
// 14 is ICS, which is the lowest API level for many apps.
// 20 is Lollipop, which is the lowest API level for the updatable system webview.
if (minSdkVersion >= 20) {
defaultConfig.versionCode += 9
} else if (minSdkVersion >= 14) {
defaultConfig.versionCode += 8
}
}
要摆脱这个问题,您可以删除不会造成任何伤害的违规代码build.gradle。
答案 2 :(得分:0)
您需要在AndroidManifest.xml内更新,而不是config.xml。