gradle需要一个小时的在线构建

时间:2016-04-05 12:36:19

标签: android build android-gradle crashlytics-android

我的app.gradle 它实际上在线构建需要一个多小时。 (通过在线构建我的意思是Gradle脱机构建未选中) 然而,在离线构建中,大约需要5-10分钟。 每当我想添加新库时,我都必须在线构建。

    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;
}
}

2 个答案:

答案 0 :(得分:0)

Android Studio转到

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

检查'Offline work'

下的'Global Gradle settings'

它会缩短gradle build次。

但是如果你想要使用新的库,那么唯一的办法是在开始时将其放置一次,让它构建一次,然后再次检查离线工作选项。

希望这适合你。

答案 1 :(得分:0)

您可能位于代理之后,您可能最近更改了密码,或者从设置角度进行了某些更改。转到

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

gradle.properties 文件中,删除/更改代理设置。它们与您的android studio代理设置不同。

遇到同样的问题,gradle过去需要一个小时才能构建。从gragle.properties文件删除代理设置后,现在需要几秒钟。