这是我的 build.gradle
应用级文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "it.myco.app.myproj"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Android Studio 高亮行
compile 'com.android.support:appcompat-v7:26.+'
与消息
avoid using + in version numbers can lead to unpredictable and unrepeatable builds
此行由 Android Studio 自动生成。为什么出现此警告消息?我需要写什么来解决警告?
最佳答案
有一天,其他人可能会对您的代码执行 git pull
,然后尝试构建 apk。此 apk 可能具有不同的行为,甚至出现构建错误或运行时错误,因为依赖项版本可能与您创建此代码时使用的依赖项版本不同。
您应该使用显式依赖版本。我建议使用最新版本。您可以搜索 bintray jcenter查看最新版本。如果您使用的是 Android Studio,File -> Project Structure -> Modules -> (your module, app usually) -> Dependencies -> Add library dependency (click the + sign)
会给你最新的版本,甚至自动添加库。
关于android - build.gradle 警告 'avoid using + in version numbers',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46793888/