Download Android Plugin For Gradle

Download Android Plugin For Gradle

Android Plugin DSL Reference. Version 3.4.0-dev. This is the DSL reference for Android Gradle Plugin. Start reading by finding the right extension type for the plugin you are using, e.g. Extension types. Listed below are the Gradle extension types used by respective plugins. The Android Studio build system is based on Gradle, and the Android Gradle plugin adds several features that are specific to building Android apps. Although the Android plugin is typically updated in lock-step with Android Studio, the plugin (and the rest of the Gradle system) can run independent of Android Studio and be updated separately.

Some Android plugin versions have issues with Gradle's build cache feature. When applied to an Android project this plugin applies workarounds for these issues based on the Android plugin and Gradle versions.

  • Supported Gradle versions: 4.1+
  • Supported Android versions: 3.0.0, 3.0.1, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4

Note: With Android 3.1.x the cache-fix plugin is only required if you are using Android's data binding feature.

Note: With Android 3.2.x the cache-fix plugin is not required.

List of issues

You can take a look at the list of issues that the plugin fixes by looking at the code of AndroidCacheFixPlugin itself. It contains a number of Workaround implementations annotated with @AndroidIssue. The Javadoc has a short description of the problem, and the annotation gives information about when the problem was introduced, what is the first version of the Android plugin that fixes it, and there's a link to the issue on Android's issue tracker:

Introduction

As part of enabling Google APIs or Firebase services in your Androidapplication you may have to add the google-services plugin to yourbuild.gradle file:

The google-services plugin has two main functions:

  1. Process the google-services.json file and produce Android resources that can be used in your application's code. See Adding the JSON File more information.
  2. Add dependencies for basic libraries required for the services you have enabled. This step requires that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file so that no dependency collisions are introduced. You can see the result of this step by running ./gradlew :app:dependencies.

Adding the JSON File

The google-services.json file is generally placed in theapp/ directory (at the root of the Android Studio app module). Asof version 2.2.0 the plugin supports build type and product flavorspecific JSON files. All of the following directory structures are valid:

Note: Providing a google-services.json file in the release directory allowsyou to maintain a separate Firebase project for your production APKs.

When product flavors are in use these more complicated directory structures arealso valid.

Processing the JSON File

The google-services.json file has the following basic structure:

The project_info object contains general information about yourproject, while each member of the client array contains informationabout the clients (Android apps) that you have added to the project.

When processing the JSON file for your Android app, the plugin only uses theclient object that matches your package name (for the current buildtype) based on the following logic:

  • For each member of the client array:
    • Check the value of client_info/android_client_info/package_name
    • If the package name matches this value, return the member object.
  • If none of the members of client match the package name, an exception is thrown.

For the rest of this document we will use {YOUR_CLIENT} to refer tothe member of the client array determined by the procedure above.

The main result of the JSON processing is to produce two XML files which youcan reference as Android resources in your Java code. Below is an example ofeach file:

app/build/generated/res/google-services/{build_type}/values/values.xml

Android

app/build/generated/res/google-services/{flavor}/{build_type}/xml/global_tracker.xml

Every value in the XML files is present in the google-services.jsonfile at the locations below. If your Android project has some configurationthat prevents you from using the google-services plugin, you cansafely recreate the XML files manually using these values:

google_app_id:

gcm_defaultSenderId:

default_web_client_id:

ga_trackingId:

firebase_database_url:

Android Gradle Plugin Version

google_api_key:

Android Studio Download Gradle

google_crash_reporting_api_key:

project_id:

Troubleshooting

Q: When building I get the following error message: 'Filegoogle-services.json is missing from module root folder. The Google ServicesPlugin cannot function without it'.

A: The Firebase console will help youdownload the google-services.json.In addition, the Quickstart guides for most APIs have instructions forgenerating this file.Once you have downloaded the google-services.json file, copy itinto the app/ folder of your Android Studio project, or into theapp/src/{build_type} folder if you are using multiple build types.

Download Android Plugin For Gradle Command

Q: I can't find the symbol 'R.string.gcm_defaultSenderId','R.xml.global_tracker', etc.

Eclipse Android Plugin

A: Make sure the package name in your build.gradle file matches thepackage name you entered when creating the google-services.jsonfile. If you are not sure, run through the getting started flow again and geta new json file.