Gradle Warning: missing groovy return statement
With Android Studio 2.2 I had to add a return void
before the final bracket in the android
section.
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}
I have been getting this same warning and I think it is incorrect. I have read through the gradle documentation and it does not appear that a return type is needed. However, the warnings bug me and the only way I could get rid of it was to add return true
.
buildTypes { android { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' return true } }}
I doubt this is the "correct" solution; however, it does remove the warnings and it doesn't cause any issues.
I fixed this by adding the recommended suppression string from inspection:
//noinspection GroovyMissingReturnStatementandroid { compileSdkVersion 25 buildToolsVersion "23.0.3"...