1

I'm working on Android Studio 3.1.4, gradle 4.4. It was fine but suddenly it get stuck in "gradle build running." There is no error messsage. I copy the project folder to another machine and it build fast and fine. I need to build it in my machine. I have uninstalled e installed the gradle and studio some times and it continue get stuck on build. Any ideas?

print screen of build messages in my machine enter image description here

print screen of success build in another machine

enter image description here

Gradle Project
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 22
    buildToolsVersion '27.0.3'
    compileOptions.encoding = 'windows-1252'

    dexOptions {
        javaMaxHeapSize "2048M"
    }

    defaultConfig {
        applicationId "br.com.savetyre"
        minSdkVersion 16
        targetSdkVersion 22
    }

    buildTypes {
        release {
            debuggable true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    google()
}

dependencies {
    implementation 'com.android.support:support-v4:22.1.1'
    implementation 'com.android.support:appcompat-v7:22.1.1'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true;
    }
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}
Gradle app
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
Julio Carvalho
  • 151
  • 2
  • 4

2 Answers2

0

As long you moved your project to new device i think no problem as stuck its working on download gradle dist, take some time normally 5-15 mins depends upon internet connection speed.

You can use some tricks to make it faster:-

  1. Goto C:\Users[USERNAME].gradle\wrapper\dists.

  2. Download appropriate gradle version as 4.4-all.

  3. Delete gradle-4.4-all.zip.lck and other files from directory..

  4. Paste the new downloaded gradle-4.4-all.zip here.

  5. Run the android studio agein.

5ec20ab0
  • 742
  • 6
  • 15
0

Because downloading Gradle takes a lot of time when your network situation is not so good, you have to download it by yourself. My solution is:

  1. Download a new version of gradle, such as gradle-4.3-all.zip, etc., and put the file in your AS Gradle location (Mac: go to the Application folder and open the package of AS, and put the new gradle in the Gradle folder. PS: If your new gradle version folder is not found, then you can create it on your own.Windows: like the previous two answers);
  2. Disconnect your Wifi or LAN;
  3. Open Android Studio 3.0 as usual;
  4. DO NOT OPEN YOUR PROJECT IMMEDIATELY, TURN TO THE PREFERENCE PART FIRST;
  5. GO TO THE GRADLE PART, DO THE SETTINGS AND SWITCH THE OFFLINE MODE ON;
  6. Open the project you want to open;
  7. Let AS to index the file and modify the gradle.properties when it is still indexing.
  8. Turn on you Wifi or LAN, and AS will download the missing file. ATTENTION: DO NOT MODIFY YOUR ANDROID MANIFEST OR OTHER FILES WHEN DOWNLOADING
  9. Close AS and reopen the project. And everything will be fine. :-)

If you still stuck at "Building Gradle Project", just redo all of these. Still not clear? Comment below.

Anubhav Gupta
  • 2,492
  • 14
  • 27