Abdul-Aziz-Niazi
Abdul-Aziz-Niazi

Reputation: 3172

gradle takes one hour online build

My app.gradle It is literally taking more than one hour in online build. (By online build I mean Gradle offline build unchecked) In offline build however, it takes around 5-10 mins. Whenever I want to add new library I will have to build online.

    buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

 repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {

compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.licianhorse.management.android"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 1
    versionName "1.1"
    multiDexEnabled true
    android {
        defaultConfig {
            manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                    onesignal_app_id: "df5308f0-b573-4247-ac2f-88924310870f",
                                    onesignal_google_project_number: "523535792051"]
        }
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}


packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
 //One Signal Dependencies
 //    compile 'com.onesignal:OneSignal:2.+@aar'
 //    compile 'com.google.android.gms:play-services-gcm:+'
 //    compile 'com.google.android.gms:play-services-analytics:+'
 //    compile "com.google.android.gms:play-services-location:+"
//One Signal Dependencies

compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:cardview-v7:21.0.3'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.jakewharton.timber:timber:2.5.0'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.crashlytics.android:crashlytics:1.1.13'
compile 'com.google.dagger:dagger-producers:2.0-beta'
compile "com.google.dagger:dagger-compiler:2.0"
compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
//    compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
//        transitive = true
//    }

compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.makeramen:roundedimageview:2.1.1'
//    compile 'com.amazonaws:aws-android-sdk-core:2.+'
//    compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
//    compile 'com.amazonaws:aws-android-sdk-s3:2.+'
//    compile 'com.amazonaws:aws-android-sdk-ddb:2.+'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.nostra13.universalimageloader:universal-image-           loader:1.9.3'
provided 'javax.annotation:jsr250-api:1.0'
compile project(":libraries:couchbase-lite-android")
compile project(":libraries:couchbase-lite-java-core")
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
}

Upvotes: 2

Views: 2216

Answers (2)

TSlegaitis
TSlegaitis

Reputation: 1310

You're probably behind a proxy, you might have recently changed your password or something has changed from settings perspective. Go to

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

in gradle.properties file, delete/ change proxy settings. They are different to your android studio proxy settings.

Had the same issue, gradle used to take an hour to build. After I deleted proxy settings from gragle.properties file, it now takes couple seconds.

Upvotes: 1

Rohit Tanwar
Rohit Tanwar

Reputation: 13

In Android Studio go to

`File -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle

Check the 'Offline work' under 'Global Gradle settings'

It will reduce gradle build time a lot.

But if you want to go with new library then only way is to put online work for once at start let it build once, then again check the offline work option.

Hope this works for you.

Upvotes: 0

Related Questions