简体   繁体   English

如何在IntelliJ IDEA(社区版)中使用Scala源代码构建Android项目?

[英]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.

相关问题 在intellij idea 13社区版中创建android测试项目 - Create android test project in intellij idea 13 community edition 如何从IntelliJ社区版将单个Android项目部署到Froyo和Honeycomb - How to deploy single Android project to both Froyo and Honeycomb from IntelliJ Community Edition 在Intellij Idea(Community Edition)2016.2.1 EAP中导入项目时出现以下错误 - I got following error when importing project in Intellij Idea (Community Edition) 2016.2.1 EAP 如何在IntelliJ IDEA中调试Android Gradle项目的特定构建变体? - How to debug specific build variant of Android Gradle project in IntelliJ IDEA? 如何在IntelliJ Idea中使用AirPush构建Android项目? - How build Android project using AirPush in IntelliJ Idea? 是否可以更改新Android应用程序的默认包名称前缀(Intellij-IDEA社区版) - Is it possible to change the default package name prefix for new Android apps (Intellij-IDEA community edition) Maven,IntelliJ Idea和Android Sources - Maven, IntelliJ Idea and Android Sources 如何在IntelliJ Idea中添加项目以构建路径 - How to add a project to build path in IntelliJ Idea 具有IntelliJ Idea ClassNotFoundException的Android上的Scala - Scala on Android with IntelliJ Idea ClassNotFoundException IntelliJ IDEA android scala应用程序 - IntelliJ IDEA android scala application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM