1

我的 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;
}
}
4

2 回答 2

0

您可能使用了代理,您可能最近更改了密码,或者从设置的角度来看发生了一些变化。去

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

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

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

于 2019-03-14T06:49:48.590 回答
0

Android Studio

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

检查'Offline work''Global Gradle settings'

时间会减少gradle build很多。

但是,如果您想使用新库,那么唯一的方法是在开始时进行一次在线工作,让它构建一次,然后再次检查离线工作选项。

希望这对你有用。

于 2016-04-05T12:41:26.717 回答