2017-09-05 7 views
1

私がminSdkVersionを21に設定している限り、すべて問題ありません。しかし、私が18に設定するとすぐに、Macbook Pro(2016)で18分ほどかかる。 特にtransformClassesDithForFullDebugは永遠に似ています。APIバージョン18でビルドに非常に時間がかかります

私のビルドのGradleファイル:私は最大5分にコンパイル時間をダウンさせる方法を探しています

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' 
apply plugin: 'me.tatarka.retrolambda' 
apply plugin: 'realm-android' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId “my.android.app” 
     //Todo: change to 18 for final export. Having minSdkVersion 21 reduces build time significantly 
     minSdkVersion 18 
     targetSdkVersion 25 
     versionCode 6 
     versionName "0.5.1" 
     testInstrumentationRunner "my.android.app.MockTestRunner" 
     setProperty("archivesBaseName", “MyApp-v$versionName") 
     multiDexEnabled true 
//  externalNativeBuild { 
//   ndk { 
//    abiFilters "armeabi-v7a", "x86" 
//   } 
//  } 
    } 

    sourceSets { 
     main { 
      jni.srcDirs = [] 
     } 
    } 

    buildTypes { 
     debug{ 
      // Disable fabric build ID generation for debug builds 
      ext.enableCrashlytics = false 
     } 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
     demo { 
      applicationIdSuffix ".demo" 
      versionNameSuffix "-demo" 
      resValue "string", "app_name", “Appname Demo" 
     } 
     full { 
      resValue "string", "app_name", “Appname” 
     } 
    } 
    compileOptions{ 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    splits { 
     abi { 
      enable true 
      reset() 
      include 'x86', 'armeabi-v7a' 
      universalApk false 
     } 
    } 

// externalNativeBuild { 
//  ndkBuild { 
//   path "src/main/jni/Android.mk" 
//  } 
// } 
} 

repositories { 
    maven { 
     url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' 
    } 

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

dependencies { 
    def supportLibVersion = '25.3.1' 
    def playServicesVersion = '10.0.1' 
    compile fileTree(dir: 'libs', include: ['*.jar']) 

    //Utils 
    compile 'com.jakewharton.timber:timber:4.5.1' 
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 
    // Because RxAndroid releases are few and far between, it is recommended you also 
    // explicitly depend on RxJava's latest version for bug fixes and new features. 
    compile 'io.reactivex.rxjava2:rxjava:2.0.9' 
    compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0' 
    compile 'org.greenrobot:eventbus:3.0.0' 
    compile 'com.birbit:android-priority-jobqueue:2.0.1' 
    compile "com.google.android.gms:play-services-gcm:$playServicesVersion" 
    compile "com.google.android.gms:play-services-vision:$playServicesVersion" 

    //UI 
    compile "com.android.support:support-dynamic-animation:$supportLibVersion" 
    compile "com.android.support:appcompat-v7:$supportLibVersion" 
    compile "com.android.support:design:$supportLibVersion" 
    compile "com.android.support:recyclerview-v7:$supportLibVersion" 
    compile 'io.realm:android-adapters:2.0.0' 
    compile 'com.commit451:PhotoView:1.2.5' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    //Used to create Picasso instance wrapping a custom OkHttp client for testing 
    compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' 

    //API calls 
    compile 'com.squareup.retrofit2:retrofit:2.2.0' 
    compile 'com.squareup.retrofit2:converter-gson:2.2.0' 
    compile 'com.squareup.retrofit2:adapter-rxjava2:2.2.0' 
    compile 'com.squareup.okhttp3:okhttp:3.4.0' 
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.0' 

    //Views injection 
    compile 'com.jakewharton:butterknife:8.5.1' 
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' 
    compile "com.android.support:support-annotations:$supportLibVersion" 

    //Analytics 
    compile "com.mixpanel.android:mixpanel-android:5.+" 
    compile "com.google.android.gms:play-services:$playServicesVersion" 

    //Crash reporting 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 

    //Debug database 
    debugCompile 'com.facebook.stetho:stetho:1.5.0' 
    debugCompile 'com.uphyca:stetho_realm:2.0.0' 

    //Testing 
    androidTestCompile "com.android.support:support-annotations:$supportLibVersion" 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 

    //For recyclerview actions 
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') { 
     // Necessary to avoid version conflicts 
     exclude group: 'com.android.support', module: 'appcompat' 
     exclude group: 'com.android.support', module: 'support-v4' 
     exclude group: 'com.android.support', module: 'support-annotations' 
     exclude module: 'recyclerview-v7' 
    } 

    testCompile 'junit:junit:4.12' 

    //Mockito and other dependencies to mock api calls 
    androidTestCompile 'org.mockito:mockito-core:2.0.2-beta' 
    androidTestCompile "com.crittercism.dexmaker:dexmaker:1.4" 
    androidTestCompile "com.crittercism.dexmaker:dexmaker-mockito:1.4" 
    androidTestCompile "com.crittercism.dexmaker:dexmaker-dx:1.4" 

    //Library that allows waiting for retrofit calls with espresso 
    androidTestCompile ('com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'){ 
     exclude module: 'okhttp' 
    } 

    androidTestCompile 'com.android.support.test:runner:0.5' 
    // Set this dependency to use JUnit 4 rules 
    androidTestCompile 'com.android.support.test:rules:0.5' 
    // Set this dependency to build and run Espresso tests 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
    // Set this dependency to build and run UI Automator tests 
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' 

    androidTestCompile 'com.linkedin.testbutler:test-butler-library:1.3.1' 

} 

。私が推測することは、transformClassesWithDexForFullDebugが本当に細かいレベルで本当に何をしているのか理解できれば、多くの助けになると思います。これは、この狂ったビルド時間を引き起こしているライブラリの依存関係を取り除くことができます。何か案は?

答えて

0

これは一般的な問題であり、多くの開発者がデバッグビルドにminSdkVersion 21を使用する理由です。私自身は2つのproductFlavorsを持っています.1つはminSdkVersion 15、もう1つは21です。私は、API 15よりもはるかに速いため、minSdkVersion 21を使用しています.18分は極端ですが、 API 21の時間を構築しますか?

も参照してください。https://developer.android.com/studio/build/optimize-your-build.html "アプリを開発する場合、可能な限りAndroid 7.0(APIレベル24)以上を搭載するデバイスに展開する必要があります。

+0

API 21内のすべてのディレクトリを削除することで2.5分にビルド時間をダウンさせるために管理:周りに54秒 – stoefln

+0

申し訳@Frankしかし、あなたはちょうど私がすでに知っていたものを説明しました。私は解決策を探しています。ビルドごとに18分待つことは私の選択肢ではありません。 – stoefln

+0

はい、私は直接の回答はありません。それは狂った違いです。 <21の生産ビルドを構築するのに長時間かかるかどうかをチェックすることから始めることができます。スプリットブロックを削除すると、1つのAPKしか作成されません。あなたはjni.srcDirsを削除しようとすることができます(なぜそこにありますか?ネイティブコードを構築していますか?) – Frank

0

私は〜/ .gradle/

rm -rf ~/.gradle/ 
関連する問題