Android Studio Version: 1.0.2 Gradle Version: 2.2.1
I am moving to android studio and I am currently trying to get a grip on gradle in order to migrate my ant build.xml to gradle or at least set up the build.gradle in a way, that I can use my old ant tasks from gradle.
Details on the current issues can be found in my other question.
Now according to the gradle documentation, chapter 6.5 here I should be able to do something like this:
task intro(dependsOn: hello) << {
println "I'm Gradle"
}
Hence I added the following to my build.gradle file:
//noinspection GroovyAssignabilityCheck
task all(dependsOn: 'release-all') << {
}
If I don't add
//noinspection GroovyAssignabilityCheck
gradle will give me a different error instead: "Cannot infer argument types".
"release-all" is an ant-task defined in my build.xml the problem is, that the gradle editor in the IDE (Android Studio) marks my task name "all" as faulty and claims: Cannot resolve symbol "all". I also tried adding above snippet within the braces of the "android" section in below build.gradle file, same error message though.
Here is my complete gradle.build file from my specific project, i.e. not the top-level build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
signingConfigs {
release {
storeFile file('android.keystore')
storePassword "pwd"
keyAlias "alias"
keyPassword "pwd"
}
}
defaultConfig {
applicationId "myapp"
minSdkVersion 14
targetSdkVersion 14
testApplicationId "myapp.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
}
}
}
//noinspection GroovyAssignabilityCheck
task all(dependsOn: 'release-all') << {
}
dependencies {
compile project(':myapplibrary')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:appcompat-v7:19.1.0'
compile files('libs/android-support-v13.jar')
compile files('libs/ormlite-android-4.38.jar')
compile files('libs/ormlite-core-4.38.jar')
compile files('libs/osmdroid-android-3.0.10-javadoc.jar')
compile files('libs/osmdroid-android-3.0.10.jar')
compile files('libs/slf4j-android-1.5.8.jar')
compile files('libs/xmltask.jar')
}
The odd thing is: When I run gradlew from the command line it doesn't actually throw any errors. Should it not technically fail while parsing the build.gradle because of above error the IDE shows me in the editor?
On an additional note - the following line is processed just fine by the editor:
//noinspection GroovyAssignabilityCheck
task all << {
}
But that's unfortunately not what I need.