问题描述
这是我的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突出显示该行
Android Studio highlights the line
compile 'com.android.support:appcompat-v7:26.+'
显示消息
此行由Android Studio自动生成.为什么显示此警告消息?我需要写些什么来解决警告?
This line is auto-generated by Android Studio. Why this warning message? What I need to write to solve the warning ?
推荐答案
总有一天,其他人可能会对您的代码执行git pull
,然后尝试构建apk.该apk可能具有不同的行为,甚至会出现构建错误或运行时错误,因为依赖版本可能与创建此代码时使用的依赖不同.
Someday, someone else may do a git pull
on your code and then try build an apk. This apk may have different behavior or even get a build error or run time error, because the dependencies version can be different than the dependencies used when you created this code.
您应该使用显式依赖项版本.我建议使用最新版本.您可以在 bintray jcenter 上搜索以查看最新版本.如果您使用的是Android Studio,File -> Project Structure -> Modules -> (your module, app usually) -> Dependencies -> Add library dependency (click the + sign)
会为您提供最新版本,甚至自动添加库.
You should use an explicit dependency version. I suggest use the newest version. You can search on bintray jcenter to see the newest version. If you are using Android Studio, File -> Project Structure -> Modules -> (your module, app usually) -> Dependencies -> Add library dependency (click the + sign)
will give you the newest version, even add library automatically.
这篇关于build.gradle警告“避免在版本号中使用+"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!