Questions tagged [android-gradle-plugin]

The Android Gradle Plugin is Android's standard build system. It is used as backing-build-system by Android Studio.

This tag is for questions about the Android Gradle plugin. The Android Gradle plugin was introduced at Google IO in 2013 and replace the legacy ant-based build system.

Resources

12908 questions
1438
votes
27 answers

What is Gradle in Android Studio?

Gradle is a bit confusing to me, and also for any new Android developer. Can anyone explain what Gradle in Android Studio is and what its purpose is? Why is it included in Android Studio?
1074
votes
35 answers

Android Studio: Add jar as library?

I'm trying to use the new Android Studio but I can't seem to get it working correctly. I'm using the Gson library to serialize/deserialize JSON-objects. But the library somehow isn't included in the build. I had created a new project with just a…
867
votes
44 answers

Android Studio Error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"

I downloaded the newest Android Studio, and I wanted to run the Android Jetpack Compose Project, but when I ran it, I got the error: > Failed to apply plugin 'com.android.internal.application'. > Android Gradle plugin requires Java 11 to run. You…
Ven Shine
  • 8,739
  • 2
  • 9
  • 24
719
votes
13 answers

What is the difference between compileSdkVersion and targetSdkVersion?

I have looked at the documentation for building with Gradle, but I'm still not sure what the difference between compileSdkVersion and targetSdkVersion is. All it says is: The `compileSdkVersion` property specifies the compilation target. Well, what…
coder123
  • 9,267
  • 5
  • 16
  • 13
657
votes
5 answers

Invoke-customs are only supported starting with android 0 --min-api 26

before i'm use build version gradle 26 but after change buildtoolsversion to 27 like as this image I am using android studio 4.2.2 recently i update all my dependency and sourceCompatibility JavaVersion.VERSION_1_10 targetCompatibility…
Rona Idea
  • 6,734
  • 2
  • 9
  • 12
633
votes
28 answers

Is it possible to use Java 8 for Android development?

Searching the web, it is not clear if Java 8 is supported for Android development or not. Before I download/setup Java 8, can some one point me at any "official" documentation that says Java 8 is or is not supported for Android development.
nPn
  • 16,254
  • 9
  • 35
  • 58
607
votes
32 answers

How to create a release signed apk file using Gradle?

I would like to have my Gradle build to create a release signed apk file using Gradle. I'm not sure if the code is correct or if I'm missing a parameter when doing gradle build? This is some of the code in my build.gradle/build.gradle.kts…
Jan-Terje Sørensen
  • 14,468
  • 8
  • 37
  • 37
603
votes
64 answers

Automatically accept all SDK licences

Since gradle android plugins 2.2-alpha4: Gradle will attempt to download missing SDK packages that a project depends on Which is amazingly cool and was know to be a JakeWharton project. But, to download the SDK library you need to: accept the…
nsvir
  • 8,781
  • 10
  • 32
  • 47
522
votes
26 answers

How to manually include external aar package using Gradle for Android

I've been experimenting with the new android build system and I've run into a small issue. I've compiled my own aar package of ActionBarSherlock which I've called 'actionbarsherlock.aar'. What I'm trying to do is actually use this aar to build my…
Miguel
  • 19,793
  • 8
  • 56
  • 46
505
votes
6 answers

Gradle DSL method not found: 'runProguard'

I get an error after updating from my last project. Not a problem in my code but I'm having trouble with build.gradle. How can I fix it? build.gradle code here: apply plugin: 'android' android { compileSdkVersion 21 buildToolsVersion…
abaci
  • 5,226
  • 2
  • 12
  • 13
462
votes
11 answers

Is it possible to declare a variable in Gradle usable in Java?

Is it possible to declare a variable in Gradle usable in Java ? Basically I would like to declare some vars in the build.gradle and then getting it (obviously) at build time. Just like a pre-processor macros in C/C++... An example of declaration…
klefevre
  • 8,595
  • 7
  • 42
  • 71
383
votes
25 answers

HttpClient won't import in Android Studio

I have a simple class written in Android Studio: package com.mysite.myapp; import org.apache.http.client.HttpClient; public class Whatever { public void headBangingAgainstTheWallExample () { HttpClient client = new…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
346
votes
21 answers

API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with 'variant.getExternalNativeBuildProviders()

Using Android Studio 3.3 Canary 11 with the gradle plugin version 3.3.0-alpha11. It throws the following error when trying to sync gradle WARNING: API 'variant.getExternalNativeBuildTasks()' is obsolete and has been replaced with…
343
votes
25 answers

Error:(1, 0) Plugin with id 'com.android.application' not found

This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message: Error:(1, 0) Plugin with id 'com.android.application' not…
Bob Kusik
  • 3,439
  • 2
  • 12
  • 3
329
votes
20 answers

Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"

Using Android Gradle plugin 0.7.0 with the following build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.7.0' } } apply plugin:…
David Lawson
  • 7,802
  • 4
  • 31
  • 37
1
2 3
99 100