[英]How to build Android project with Scala sources in IntelliJ IDEA (Community Edition)?
I am trying to build an Android project with Scala sources in IntelliJ IDEA (Community Edition). 我正在尝试在IntelliJ IDEA(社区版)中使用Scala源代码构建一个Android项目。 I am using Scala sources from Java files: auto-complete works correctly, but build cannot resolve Scala classes in Java: cannot find symbol class MyScalaClass
. 我正在使用Java文件中的Scala源代码:自动完成功能可以正常工作,但是build无法解析Java中的Scala类: cannot find symbol class MyScalaClass
。
(I managed that in Eclipse, but Scala support in Eclipse is poor.) (我在Eclipse中进行了管理,但是Eclipse对Scala的支持很差。)
Any hints or tutorials? 有任何提示或教程吗?
Update: I have added Scala module in addition to Android module. 更新:除了Android模块之外,我还添加了Scala模块。 Now, build fails during generating classes.dex
with message: 现在,在生成带有消息的classes.dex
期间构建失败:
Error: trouble writing output: format == null
I found that it is a limitation of Dalvik: issue 7147 . 我发现这是Dalvik的局限性: 发行号7147 。
How can I strip unused methods/classes in IDEA without using Ant script? 如何在不使用Ant脚本的情况下剥离IDEA中未使用的方法/类? (I was using ProGuard in Ant script, but I was unable make IDEA to parse Scala error messages from Ant results.) (我在Ant脚本中使用ProGuard,但是无法使IDEA解析来自Ant结果的Scala错误消息。)
The scala/java system requires that you: scala / java系统要求您:
- Build scala first, giving the compiler both scala and java files. -首先构建scala,为编译器提供scala和java文件。
- Build the java sources with the compiled scala classes in the path for javac. -使用javac路径中的已编译scala类构建Java源代码。
The second is probably what you lack. 第二个可能是您缺少的东西。 Refer to how to add directory to classpath in an application run profile in intellij idea? 请参阅如何在IntelliJ IDEA的应用程序运行配置文件中将目录添加到类路径中? to add a classpath to Intellij (I suppose you did it for the android runtime, so you probably already know it). 向Intellij添加类路径(我想您是在android运行时完成的,所以您可能已经知道了)。
You should use ProGuard to strip down unused classes. 您应该使用ProGuard精简未使用的类。
Follow the instructions here (Specifically take a look at the progaurd-project.txt
: 请按照此处的说明进行操作(具体看一下progaurd-project.txt
:
https://github.com/yareally/android-scala-intellij-no-sbt-plugin https://github.com/yareally/android-scala-intellij-no-sbt-plugin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.