Android Studio Stuck At Gradle Build Running



Edit page

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process while allowing you to define flexible custom build configurations. So, with the help of Gradle, you can do the building, testing and deployment of your application and the files which are responsible for this type of automation is the “ Build.

  1. Or, when you are using Android Studio to run your project, pass it in your command-line options under Preferences. Estimates that this will reduce 5-10% of your build time. More on multiple APKs. Include minimal resources Avoid compiling unnecessary resources that you aren't testing. Including, but not limited to, additional language localizations, and screen density resources.
  2. You need to re-run generategradle.py whenever BUILD.gn files change. Pass -canary or -beta to avoid the “A newer version of gradle is available” notification. After regenerating, Android Studio should prompt you to “Sync”. If it doesn't, try some of the following options: File - “Sync Project with Gradle Files” Button with two arrows on the right side of the top strip. Help - Find Action - “Sync Project with Gradle Files”.

Download Gradle Android Studio

Introduction

Android Studio plugins extend or add functionality to the Android Studio IDE.Plugins can be written in Kotlin or Java, or a mix of both, and are created using IntelliJ IDEA and the IntelliJ Platform.It’s also helpful to be familiar with Java Swing.Once completed, plugins can be packaged and distributed at JetBrains Plugin Repository.

Android studio stuck at gradle build running system

Android Studio plugins are not Android modules or apps to run in the Android operating system, such as smartphones or tablets.

Android Studio Gradle Settings

Configuring IntelliJ Platform Projects for Android Studio Plugin Development

Android Studio Stuck At Gradle Build Running

To create a new Android Studio plugin project, follow the tutorial on the Getting Started with Gradle page.The tutorial produces a skeleton project suitable to use as a starting point for an Android Studio plugin.On the New Project Configuration Screen of the New Project Wizard tutorial, choose Gradle from the product category pane as described in the tutorial, notAndroid.

Some minor modifications to the skeleton project are needed, as discussed below.

Matching Versions of the IntelliJ Platform with the Android Studio Version

For API compatibility, it is essential to match the version of the IntelliJ Platform APIs used for plugin development with the target version of Android Studio.The version number of Android Studio contains the version of the underlying IntelliJ Platform APIs that were used to build it.

To find the version of the IntelliJ Platform used to build Android Studio, use the Android Studio About dialog screen.An example is shown below.In this case, the (BRANCH.BUILD.FIX) version of the IntelliJ Platform is 191.8026.42, which corresponds to the IntelliJ IDEA version 2019.1.4.The build.gradle configuration steps section below explains how to set the IntelliJ Platform version to match the target version of Android Studio.

Configuring the Plugin build.gradle File

Gradle version android studio

The use-case of developing for a non-IntelliJ IDEA IDE is reviewed in the Plugins Targeting Alternate IntelliJ Platform-Based IDEs section of the Configuring Gradle for IntelliJ Platform Plugins page.The particular example in that section discusses configuring a plugin project for PhpStorm, so the details for an Android Studio plugin project are reviewed here.

Here are the steps to configure the build.gradle file for developing a plugin to target Android Studio:

  • The Gradle plugin attributes describing the configuration of the IntelliJ Platform used to build the plugin project must be explicitly set.Continuing with the example above, set the intellij.version value to 191.8026.42.Alternatively, specify intellij.localPath to refer to a local installation of Android Studio.
  • Android Studio plugin projects that use APIs from the android plugin must declare a dependency on that plugin. Declare the dependency in build.gradle using the Gradle plugin intellij.plugins attribute, which in this case lists the directory name of the plugin.
  • The best practice is to use the target version of Android Studio as the IDE Development Instance.Set the Development Instance to the (user-specific) absolute path to the target Android Studio application.
Android Studio Stuck At Gradle Build Running

The snippet below is an example of configuring the Setup and Running DSLs in a build.gradle specific to developing a plugin targeted at Android Studio.

intellij{// Define IntelliJ Platform against which to build the plugin project.version'191.8026.42'// Same IntelliJ IDEA version (2019.1.4) as target 3.5 Android Studiotype'IC'// Use IntelliJ IDEA CE because it's the basis of the IntelliJ Platform// Require the Android plugin, Gradle will match the plugin version to intellij.versionplugins'android'}runIde{// Absolute path to installed target 3.5 Android Studio to use as IDE Development Instance// The 'Contents' directory is macOS specific.ideDirectory'/Applications/Android Studio.app/Contents'}

Configuring the Plugin plugin.xml File

When using APIs from the android plugin, declare a dependency:

As discussed in the Plugin Dependencies section of this guide, a plugin’s dependency on Modules Specific to Functionality must be declared in plugin.xml.When using Android Studio-specific features (APIs), a dependency on com.intellij.modules.androidstudio must be declared as shown in the code snippet below.Otherwise, if only general IntelliJ Platform features (APIs) are used, then a dependency on com.intellij.modules.platform must be declared as discussed in Plugin Compatibility with IntelliJ Platform Products.

<depends>com.intellij.modules.androidstudio</depends>

Additional Articles and Resources

  • Discussion of extending Android Lint - How to Register AndroidLintInspectionBase in IntelliJIdea Plugin
  • Grzegorz Matyszczak’s article How I Automated Creating Files for a New Screen with My Own Android Studio Plugin
  • Marcos Holgado’s article series Write an Android Studio Plugin (Part 1)

Open Source Plugins for Android Studio

Android Studio Stuck At Gradle Build Running

When learning new development configurations, it is helpful to have some representative projects for reference:

  • ADB Idea plugin for Android Studio and Intellij IDEA that speeds up Android development.
  • Android postfix plugin for Android Studio.
  • Flutter Plugin.
  • Bal Sikandar’s list of Android Studio plugins.

FAQ

How To Sync Gradle Project

Use com.android.tools.idea.gradle.project.sync.GradleSyncInvoker.requestProjectSync() for programmatic synchronization.