我的构建在Android Studio中需要很长时间,超过2分钟,有时3分钟.我尝试了StackOverflow中解释的一些方法来加速构建时间,但它并没有解决我的问题.
app模块的build.gradle代码如下:
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' }}// Adding The GIT SHA to Crashlytics crash reportingdef gitSha = 'git rev-parse --short head'.execute([], project.rootDir).text.trim()androID { compileSdkVersion 22 buildToolsversion "22.0.1" defaultConfig { applicationID "com.moymer" minSdkVersion 11 targetSdkVersion 22 multIDexEnabled true versionCode 5 versionname "2.0.0" buildConfigFIEld "String", "GIT_SHA", "\"${gitSha}\"" } buildTypes { release { MinifyEnabled false proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } deBUG { testCoverageEnabled true } }}dependencIEs { compile filetree(include: ['*.jar'], dir: 'libs') compile 'com.androID.support:appcompat-v7:22.2.0' compile 'com.Google.androID.gms:play-services:7.5.0' compile 'com.androID.support:design:22.2.0' compile 'com.github.nirhart:parallaxscroll:1.0' compile 'com.androID.support:multIDex:1.0.0' compile('com.crashlytics.sdk.androID:crashlytics:2.4.0@aar') { transitive = true; } compile 'in.srain.cube:grID-vIEw-with-header-footer:1.0.12' compile 'com.androID.support:recyclervIEw-v7:23+' compile 'com.squareup:otto:1.3.8' compile 'com.androID.support:percent:23.0.0' compile 'com.jakewharton.timber:timber:3.1.0' compile project(':androIDffmpeglibrary')}
我的gradle.propertIEs文件如下:
org.gradle.daemon=trueorg.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.enCoding=UTF-8org.gradle.parallel=trueorg.gradle.configureondemand=true
解决方法:
你有11个依赖项和一个额外的插件.至少有一个(androIDffmpeglibrary)似乎涉及NDK.这不会很快,特别是取决于你的构建硬件.
如果你想要更快的构建,摆脱一些垃圾.例如,一年多有finer-grained Play Services SDK dependencies;只使用你需要的部分,而不是“除了厨房水槽之外的所有东西”游戏服务神器.反过来,这可能允许您转储multIDex,因为您可能会回落到64K DEX方法参考限制之下.
AndroID Tools团队正致力于提高构建速度,这将在更新版本的Gradle AndroID插件中显示.那必须在你的顶级build.gradle文件中,因为我在这里看不到你在哪里.确保您使用最新版本,并在新版本发布时不断更新.
总结以上是内存溢出为你收集整理的为什么我的构建需要这么长时间的Android Studio?全部内容,希望文章能够帮你解决为什么我的构建需要这么长时间的Android Studio?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)