使用Android Studio的Scala [英] Scala with android studio

查看:400
本文介绍了使用Android Studio的Scala的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Android studio 3.2的Java项目,我想添加一些Scala文件. 我已经阅读过在Android Studio中将Scala与Java结合使用 我对此有一些疑问.

I have a project in Java with Android studio 3.2, and I want to add some Scala files. I have already read this Using Scala with Java in Android Studio and I have some questions about it.

据我了解,当您想要拥有Java和Scala文件时,最好使用gradle scala插件而不是scala插件. 但是因为这个话题太老了,所以我想知道它是否仍然是真的,还是我应该使用scala插件.

From what I understand, when you want to have java and scala files, it's better to use the gradle scala plugin instead of the scala plugin. But because the topic is rather old, I was wondering if it's still true, or if I should use the scala plugin.

感谢您的回答和建议!

推荐答案

我创建了这个插件

I create fork this plugin https://github.com/AllBus/gradle-android-scala-plugin This version of the plugin supports Android 28 and Gradle 5.3

将此代码写入build.gradle文件

write this code in build.gradle file

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
    dependencies {

        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.github.AllBus:gradle-android-scala-plugin:3.3.2'
    }
}

并添加app/build.gradle

and add app/build.gradle

apply plugin: "com.android.application"
apply plugin: "jp.leafytree.android-scala"

android {
    compileSdkVersion 28
    ...

}

dependencies {
    implementation "org.scala-lang:scala-library:2.11.12"
    ...

}

这篇关于使用Android Studio的Scala的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆