Sri*_*ddy 43 groovy android gradle build.gradle android-gradle-plugin
我的gradle构建文件中有以下警告
并非所有执行路径都返回值
此检查报告在返回方法结束时缺少groovy return语句
这是该文件中的代码
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ac.company.srikar.quickhelpindia"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉这里的问题是什么以及如何摆脱这个警告.
Sor*_*ner 50
使用Android Studio 2.2,我必须return void
在该android
部分的最后一个括号之前添加一个.
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
standard {
applicationId "com.example.app.standard"
}
free {
applicationId "com.example.app.free"
}
}
// `return void` removes the lint error: `Not all execution paths return a value`.
return void
}
Run Code Online (Sandbox Code Playgroud)
mat*_*red 16
我一直得到同样的警告,我认为这是不正确的.我已阅读了gradle文档,但似乎不需要返回类型.然而,这些警告让我感到烦恼,我摆脱它的唯一方法就是添加return true
.
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
return true
}
}
}
Run Code Online (Sandbox Code Playgroud)
我怀疑这是"正确的"解决方案; 但是,它会删除警告并且不会导致任何问题.
JL *_*est 12
我通过添加检查中推荐的抑制字符串来修复此问题:
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
...
Run Code Online (Sandbox Code Playgroud)
当我指定了我摆脱这个警告,minifyEnabled
和shrinkResources
.
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7601 次 |
最近记录: |