gpt4 book ai didi

android - Build.gradle 不接受版本代码作为字符串

转载 作者:行者123 更新时间:2023-12-05 00:14:21 25 4
gpt4 key购买 nike

1 到 9 的版本代码更新为 string 但是,当更新到 10 时会出现编译时错误:

Cannot cast object '10' with class 'java.lang.String' to class 'java.lang.Integer'

versionCode = "10"

如果我将版本代码设为整数 10,我可以生成已签名的 apk,但无法上传到 Play 商店。

项目最初是用eclipse做的,后来迁移到android studio

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}

安卓{ 编译SDK版本23 buildToolsVersion '23.0.2' useLibrary 'org.apache.http.legacy'

defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode = 10
versionName = "1.1.12"
multiDexEnabled true
}

lintOptions {
// set to true to turn off analysis progress reporting by lint
quiet true
// if true, stop the gradle build if errors are found
abortOnError false
// if true, only report errors
ignoreWarnings true
}
buildTypes {
release {
minifyEnabled false
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}




sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}

最佳答案

Cannot cast object '10' with class 'java.lang.String' to class 'java.lang.Integer'
  1. versionCode 必须是整数值。

  2. 移除 =

android:版本号

An integer value that represents the version of the application code, relative to other versions. The value is an integer so that other applications can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value. The system does not enforce this behavior, but increasing the value with successive releases is normative.

  minSdkVersion 16
targetSdkVersion 23
versionCode 10
versionName "1.1.12"
multiDexEnabled true

然后清理-重建-运行

仅供引用

 versionCode Integer.parseInt("10") // String to Integer convert

关于android - Build.gradle 不接受版本代码作为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35132626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com