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
231
votes
16 answers

The number of method references in a .dex file cannot exceed 64k API 17

I am building an app with SugarORM Library but when I try to build the project for API 17 (didn't check for others) it shows build error. Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild…
230
votes
3 answers

How to use ThreeTenABP in Android Project

I'm using Android Studio 2.1.2 and my Java setup is the following: >java -version > openjdk version "1.8.0_91" > OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10.1-b14) > OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode) I…
kael
  • 6,585
  • 5
  • 21
  • 27
229
votes
23 answers

Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it"

I updated my project to the latest Play services classpath 'com.google.gms:google-services:1.5.0-beta2'. I am also using the latest version of playservices in my app.gradle file as: compile…
williamj949
  • 11,166
  • 8
  • 37
  • 51
224
votes
7 answers

How can I fix "unexpected element found in " error?

All of a sudden, I am getting this build error in my Android project: unexpected element found in How do I fix it?
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
220
votes
2 answers

What is the syntax for writing comments in build.gradle file?

Looking down this build.gradle file apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "package.myapp" minSdkVersion 19 …
Machado
  • 14,105
  • 13
  • 56
  • 97
216
votes
26 answers

No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. when updating to Support Library 26.0.0

I've got this issue while updating to the latest Support Library version 26.0.0 (https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0): Error:(18, 21) No resource found that matches the given name: attr …
216
votes
26 answers

Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat

If I run gradle assembleDebug from the command line, I am suddenly getting this error: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.util.DexException: Multiple dex files define…
xrd
  • 4,019
  • 6
  • 30
  • 39
211
votes
12 answers

How to generate buildConfigField with String type

In my Android Studio project there are two build configuration with some buildConfigField: buildTypes { def SERVER_URL = "SERVER_URL" def APP_VERSION = "APP_VERSION" debug { buildConfigField "String", SERVER_URL,…
Abdullah
  • 7,143
  • 6
  • 25
  • 41
209
votes
22 answers

ionic 2 - Error Could not find an installed version of Gradle either in Android Studio

I create ionic 2 project and add diagnostic cordova plugin like this : ionic plugin add cordova.plugins.diagnostic npm install --save @ionic-native/diagnostic and add android platform like this : ionic platform add android@latest but when build…
Reza Mazarlou
  • 2,986
  • 4
  • 22
  • 31
208
votes
24 answers

Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK - Android

I know there are lots of questions similiar to this one, but i couldn't find a solution for my problem in any of those. Besides, I'll provide details for my specific case. I coded an Ionic project in Ubuntu 16.04 LTS, and now I have to build it for…
rbenvenuto
  • 2,415
  • 2
  • 12
  • 20
207
votes
6 answers

Why are build types distinct from product flavors?

Preface: this is not a question about how to use build types and product flavors in an Android app. I understand the basic concepts involved. This question is more about trying to understand which configuration should be specified in a build type,…
stkent
  • 19,772
  • 14
  • 85
  • 111
203
votes
28 answers

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'

Suddenly when Syncing Gradle, I get this error: WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'. It will be removed at the end of 2019. For more information, see…
200
votes
40 answers

Android- Error:Execution failed for task ':app:transformClassesWithDexForRelease'

The Problem is that i am able to run my app when i change to debug mode but it fails when i switch to release mode. Exception: **FAILURE: Build failed with an exception.** > Execution failed for task ':app:transformClassesWithDexForRelease'. >…
192
votes
2 answers

What's the difference between buildscript and allprojects in build.gradle?

On a multi-project gradle build, can someone tell me what exactly is the difference between the "allprojects" section and the "buildscript" one? Both have a repositories and dependencies task. Is allprojects for my project? What about…
kidoher
  • 2,297
  • 2
  • 12
  • 19
190
votes
19 answers

How to set compileJava' task ( 11) and 'compileKotlin' task (1.8) jvm target compatibility to the same Java version in build.gradle.kts?

Build.gradle.kts buildscript { repositories { google() mavenCentral() gradlePluginPortal() } dependencies { classpath ("com.android.tools.build:gradle:7.0.2") classpath…