How to set up Kotlin’s byte code version in Gradle project to Java 8?

As Mark pointed out on Debop’s answer, you have to configure both compileKotlin and compileTestKotlin. You can do it without duplication this way: tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { jvmTarget = “1.8” } } For a pure Kotlin project, I don’t think the options sourceCompatibility and targetCompatibility do anything, so you may be able to remove them. … Read more

Extract common methods from Gradle build script

Building on Peter’s answer, this is how I export my methods: Content of helpers/common-methods.gradle: // Define methods as usual def commonMethod1(param) { return true } def commonMethod2(param) { return true } // Export methods by turning them into closures ext { commonMethod1 = this.&commonMethod1 otherNameForMethod2 = this.&commonMethod2 } And this is how I use those … Read more

How to download javadocs and sources for jar using Gradle 2.0?

I guess your question is related to a dev workspace, here are links explaining how to add the required configuration in Gradle using the IDEs’ plugins: For Eclipse: apply plugin: ‘java’ apply plugin: ‘eclipse’ eclipse { classpath { downloadJavadoc = true downloadSources = true } } For IntelliJ & Android Studio apply plugin: ‘java’ apply … Read more

Gradle alternate to mvn install

sdk/build.gradle: apply plugin: “maven” group = “foo” version = “1.0” example/build.gradle: repositories { mavenLocal() } dependencies { compile “foo:sdk:1.0” } $sdk> gradle install $example> gradle build

Android Studio: Plugin with id ‘android-library’ not found

Instruct Gradle to download Android plugin from Maven Central repository. You do it by pasting the following code at the beginning of the Gradle build file: buildscript { repositories { mavenCentral() } dependencies { classpath ‘com.android.tools.build:gradle:1.1.1’ } } Replace version string 1.0.+ with the latest version. Released versions of Gradle plugin can be found in … Read more

Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes?

You can add below 2 lines into your gradle.properties file: android.useAndroidX=true android.enableJetifier=true Note to check, to not repeat any line that already exists (and ensure existing are true). Details: If you want to use androidx-namespaced libraries in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher … Read more

tech