使用Scala与Gradle for Android项目

似乎有一个内存泄漏的地方。

在IntelliJ中设置项目并使用Gradle包装器时:

./gradlew assembleDebug --debug

大约5分钟后,我得到以下内容:

 14:30:15.245 [INFO] [org.gradle.api.Project] processing scala/collection/SeqViewLike$$anon$5.class... 14:30:53.132 [INFO] [org.gradle.api.Project] processing scala/collection/SeqViewLike$$anon$6.class... 14:33:51.027 [ERROR] [org.gradle.api.Project] 14:33:51.028 [ERROR] [org.gradle.api.Project] UNEXPECTED TOP-LEVEL ERROR: 14:33:51.028 [ERROR] [org.gradle.api.Project] java.lang.OutOfMemoryError: Java heap space 14:33:51.028 [ERROR] [org.gradle.api.Project] at java.util.HashMap.<init>(HashMap.java:209) 14:33:51.029 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.LocalVariableInfo.<init>(LocalVariableInfo.java:66) 14:33:51.029 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.LocalVariableExtractor.<init>(LocalVariableExtractor.java:72) 14:33:51.029 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.LocalVariableExtractor.extract(LocalVariableExtractor.java:54) 14:33:51.029 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:49) 14:33:51.030 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98) 14:33:51.030 [ERROR] [org.gradle.api.Project] at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72) 14:33:51.030 [ERROR] [org.gradle.api.Project] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:303) 14:33:51.030 [ERROR] [org.gradle.api.Project] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139) 14:33:51.031 [ERROR] [org.gradle.api.Project] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94) 14:33:51.031 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.processClass(Main.java:682) 14:33:51.031 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634) 14:33:51.031 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.access$600(Main.java:78) 14:33:51.032 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572) 14:33:51.032 [ERROR] [org.gradle.api.Project] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) 14:33:51.032 [ERROR] [org.gradle.api.Project] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) 14:33:51.034 [ERROR] [org.gradle.api.Project] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) 14:33:51.034 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.processOne(Main.java:596) 14:33:51.034 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498) 14:33:51.034 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264) 14:33:51.035 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.run(Main.java:230) 14:33:51.035 [ERROR] [org.gradle.api.Project] at com.android.dx.command.dexer.Main.main(Main.java:199) 14:33:51.035 [ERROR] [org.gradle.api.Project] at com.android.dx.command.Main.main(Main.java:103) 

我正在使用Scala 2.9.3但遇到了与2.10.x相同的问题。

这是我的build.gradle

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' repositories { mavenCentral() } android { compileSdkVersion 19 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 19 } } dependencies { compile 'com.android.support:appcompat-v7:+' // Scala. compile 'org.scala-lang:scala-library:2.9.3', 'org.scala-lang:scala-compiler:2.9.3' } 

有人用Gradle + Scala成功编译Android项目。

谢谢!

Solutions Collecting From Web of "使用Scala与Gradle for Android项目"