Giter VIP home page Giter VIP logo

gradle-android-scala-plugin's Introduction

gradle-android-scala-plugin

gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at https://github.com/saturday06/gradle-android-scala-plugin/tree/master/sample

Table of Contents generated with DocToc

Supported versions

Scala Gradle Android Plugin compileSdkVersion buildToolsVersion
2.11.7 2.2.1 1.1.3, 1.2.3, 1.3.1 21, 22, 23 21.1.2, 22.0.1
2.10.5 2.2.1 1.1.3, 1.2.3, 1.3.1 21, 22, 23 21.1.2, 22.0.1

If you want to use older build environment, please try android-scala-plugin-1.3.2

Installation

1. Add buildscript's dependency

build.gradle

buildscript {
    dependencies {
        classpath "com.android.tools.build:gradle:1.3.1"
        classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.4"
    }
}

2. Apply plugin

build.gradle

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

3. Add scala-library dependency

The plugin decides scala language version using scala-library's version.

build.gradle

dependencies {
    compile "org.scala-lang:scala-library:2.11.7"
}

4. Put scala source files

Default locations are src/main/scala, src/androidTest/scala. You can customize those directories similar to java.

build.gradle

android {
    sourceSets {
        main {
            scala {
                srcDir "path/to/main/scala" // default: "src/main/scala"
            }
        }

        androidTest {
            scala {
                srcDir "path/to/androidTest/scala" // default: "src/androidTest/scala"
            }
        }
    }
}

5. Implement a workaround for DEX 64K Methods Limit

The Scala Application generally suffers DEX 64K Methods Limit. To avoid it we need to implement one of following workarounds.

5.1. Option 1: Use ProGuard

If your project doesn't need to run androidTest, You can use proguard to reduce methods.

Sample proguard configuration here:

proguard-rules.txt

-dontoptimize
-dontobfuscate
-dontpreverify
-dontwarn scala.**
-ignorewarnings
# temporary workaround; see Scala issue SI-5397
-keep class scala.collection.SeqLike {
    public protected *;
}

From: hello-scaloid-gradle

5.2. Option 2: Use MultiDex

Android comes with built in support for MultiDex. You will need to use MultiDexApplication from the support library, or modify your Application subclass in order to support versions of Android prior to 5.0. You may still wish to use ProGuard for your production build.

Using MultiDex with Scala is no different than with a normal Java application. See the Android Documentation and MultiDex author's Documentation for details.

It is recommended that you set your minSdkVersion to 21 or later for development, as this enables an incremental multidex algorithm to be used, which is significantly faster.

build.gradle

repositories {
    jcenter()
}

android {
    defaultConfig {
        multiDexEnabled true
    }
}

dependencies {
    compile "org.scala-lang:scala-library:2.11.7"
    compile "com.android.support:multidex:1.0.1"
}

Change application class.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jp.leafytree.sample">
    <application android:name="android.support.multidex.MultiDexApplication">
</manifest>

If you use customized application class, please read next section.

To test MultiDexApplication, custom instrumentation test runner should be used. See also https://github.com/casidiablo/multidex/blob/publishing/instrumentation/src/com/android/test/runner/MultiDexTestRunner.java

build.gradle

android {
    defaultConfig {
        testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
    }
}

dependencies {
    compile "org.scala-lang:scala-library:2.11.7"
    compile "com.android.support:multidex:1.0.1"
    androidTestCompile "com.android.support:multidex-instrumentation:1.0.1", { exclude module: "multidex" }
}
5.2.1. Setup application class if you use customized one

Since application class is executed before multidex configuration, Writing custom application class has stll many pitfalls.

The application class must extend MultiDexApplication or override Application#attachBaseContext like following.

MyCustomApplication.scala

package my.custom.application

import android.app.Application
import android.content.Context
import android.support.multidex.MultiDex

object MyCustomApplication {
  var globalVariable: Int = _
}

class MyCustomApplication extends Application {
  override protected def attachBaseContext(base: Context) = {
    super.attachBaseContext(base)
    MultiDex.install(this)
  }
}

You need to remember:

NOTE: The following cautions must be taken only on your android Application class, you don't need to apply this cautions in all classes of your app

  • The static fields in your application class will be loaded before the MultiDex#installbe called! So the suggestion is to avoid static fields with types that can be placed out of main classes.dex file.
  • The methods of your application class may not have access to other classes that are loaded after your application class. As workaround for this, you can create another class (any class, in the example above, I use Runnable) and execute the method content inside it. Example:
  override def onCreate = {
    super.onCreate

    val context = this
    new Runnable {
      override def run = {
        variable = new ClassNeededToBeListed(context, new ClassNotNeededToBeListed)
        MyCustomApplication.globalVariable = 100
      }
    }.run
  }

This section is copyed from README.md for multidex project

Configuration

You can configure scala compiler options as follows:

build.gradle

tasks.withType(ScalaCompile) {
    // If you want to use scala compile daemon
    scalaCompileOptions.useCompileDaemon = true
    // Suppress deprecation warnings
    scalaCompileOptions.deprecation = false
    // Additional parameters
    scalaCompileOptions.additionalParameters = ["-feature"]
}

Complete list is described in http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.scala.ScalaCompileOptions.html

Complete example of build.gradle with manually configured MultiDexApplication

build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:1.3.1"
        classpath "jp.leafytree.gradle:gradle-android-scala-plugin:1.4"
    }
}

repositories {
    jcenter()
}

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

android {
    compileSdkVersion "android-22"
    buildToolsVersion "22.0.1"

    defaultConfig {
        targetSdkVersion 22
        testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner"
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    productFlavors {
        dev {
            minSdkVersion 21 // To reduce compilation time
        }

        prod {
            minSdkVersion 8
        }
    }

    sourceSets {
        main {
            scala {
                srcDir "path/to/main/scala" // default: "src/main/scala"
            }
        }

        androidTest {
            scala {
                srcDir "path/to/androidTest/scala" // default: "src/androidTest/scala"
            }
        }
    }
}

dependencies {
    compile "org.scala-lang:scala-library:2.11.7"
    compile "com.android.support:multidex:1.0.1"
    androidTestCompile "com.android.support:multidex-instrumentation:1.0.1", { exclude module: "multidex" }
}

tasks.withType(ScalaCompile) {
    scalaCompileOptions.deprecation = false
    scalaCompileOptions.additionalParameters = ["-feature"]
}

Changelog

  • 1.4 Support android plugin 1.1.3. Manual configuration for dex task is now unnecessary (contributed by sgrif)
  • 1.3.2 Fix unexpected annotation processor's warnings
  • 1.3.1 Support android plugin 0.12.2
  • 1.3 Incremental compilation support in scala 2.11
  • 1.2.1 Fix binary compatibility with JDK6
  • 1.2 Incremental compilation support in scala 2.10 / Flavors support
  • 1.1 MultiDexApplication support
  • 1.0 First release

gradle-android-scala-plugin's People

Contributors

faqqe avatar kamillelonek avatar saturday06 avatar sgrif avatar timgreen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-android-scala-plugin's Issues

sample project doesn't work

It happens in fresh version
commit 65a2e86
Author: Isamu Mogi [email protected]
Date: Tue Nov 4 21:47:49 2014 +0900

maaaacy:hello $ pwd
/Users/tsypa/scala/github/gradle-android-scala-plugin/sample/hello
maaaacy:hello $ ./gradlew --info tasks
Starting Build
================================================ Start building buildSrc
Evaluating root project 'buildSrc' using build file '/Users/tsypa/scala/github/gradle-android-scala-plugin/buildSrc/build.gradle'.
Selected primary task 'build' from project :
:compileJava (Thread[main,5,main]) started.
:buildSrc:compileJava
Skipping task ':compileJava' as it has no source files.
:buildSrc:compileJava UP-TO-DATE
:compileJava (Thread[main,5,main]) completed. Took 0.027 secs.
:compileGroovy (Thread[main,5,main]) started.
:buildSrc:compileGroovy
Skipping task ':compileGroovy' as it is up-to-date (took 0.209 secs).
:buildSrc:compileGroovy UP-TO-DATE
:compileGroovy (Thread[main,5,main]) completed. Took 0.252 secs.
:processResources (Thread[main,5,main]) started.
:buildSrc:processResources
Skipping task ':processResources' as it has no source files.
:buildSrc:processResources UP-TO-DATE
:processResources (Thread[main,5,main]) completed. Took 0.0030 secs.
:classes (Thread[main,5,main]) started.
:buildSrc:classes
Skipping task ':classes' as it has no actions.
:buildSrc:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.0030 secs.
:jar (Thread[main,5,main]) started.
:buildSrc:jar
Skipping task ':jar' as it is up-to-date (took 0.038 secs).
:buildSrc:jar UP-TO-DATE
:jar (Thread[main,5,main]) completed. Took 0.048 secs.
:assemble (Thread[main,5,main]) started.
:buildSrc:assemble
Skipping task ':assemble' as it has no actions.
:buildSrc:assemble UP-TO-DATE
:assemble (Thread[main,5,main]) completed. Took 0.0010 secs.
:compileTestJava (Thread[main,5,main]) started.
:buildSrc:compileTestJava
Skipping task ':compileTestJava' as it has no source files.
:buildSrc:compileTestJava UP-TO-DATE
:compileTestJava (Thread[main,5,main]) completed. Took 0.0010 secs.
:compileTestGroovy (Thread[main,5,main]) started.
:buildSrc:compileTestGroovy
Skipping task ':compileTestGroovy' as it has no source files.
:buildSrc:compileTestGroovy UP-TO-DATE
:compileTestGroovy (Thread[main,5,main]) completed. Took 0.0020 secs.
:processTestResources (Thread[main,5,main]) started.
:buildSrc:processTestResources
Skipping task ':processTestResources' as it has no source files.
:buildSrc:processTestResources UP-TO-DATE
:processTestResources (Thread[main,5,main]) completed. Took 0.0020 secs.
:testClasses (Thread[main,5,main]) started.
:buildSrc:testClasses
Skipping task ':testClasses' as it has no actions.
:buildSrc:testClasses UP-TO-DATE
:testClasses (Thread[main,5,main]) completed. Took 0.0040 secs.
:test (Thread[main,5,main]) started.
:buildSrc:test
file or directory '/Users/tsypa/scala/github/gradle-android-scala-plugin/buildSrc/build/classes/test', not found
Skipping task ':test' as it has no source files.
:buildSrc:test UP-TO-DATE
:test (Thread[main,5,main]) completed. Took 0.0050 secs.
:check (Thread[main,5,main]) started.
:buildSrc:check
Skipping task ':check' as it has no actions.
:buildSrc:check UP-TO-DATE
:check (Thread[main,5,main]) completed. Took 0.0020 secs.
:build (Thread[main,5,main]) started.
:buildSrc:build
Skipping task ':build' as it has no actions.
:buildSrc:build UP-TO-DATE
:build (Thread[main,5,main]) completed. Took 0.0020 secs.
================================================ Finished building buildSrc
Stopped 0 compiler daemon(s).
Settings evaluated using empty settings script.
Projects loaded. Root project using build file '/Users/tsypa/scala/github/gradle-android-scala-plugin/sample/hello/build.gradle'.
Included projects: [root project 'hello']
Evaluating root project 'hello' using build file '/Users/tsypa/scala/github/gradle-android-scala-plugin/sample/hello/build.gradle'.

FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/tsypa/scala/github/gradle-android-scala-plugin/sample/hello/build.gradle' line: 17

  • What went wrong:
    A problem occurred evaluating root project 'hello'.

    jp/leafytree/gradle/AndroidScalaPlugin : Unsupported major.minor version 51.0

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 6.56 secs
Stopped 0 compiler daemon(s).
maaaacy:hello $

Unit Test / Scalatest support

with android-gradle 1.1+ execution of unit tests are possible,
added scalatest directly or with junitrunner would be nice

Library project's instrumentTest failed

> gradlew clean connectedInstrumentTest
:lib1:dexDebugTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':lib1:dexDebugTest'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        C:\Users\foo\AppData\Local\Android\android-sdk\build-tools\19.0.1\dx.bat --dex --output C:\Users\foo\Documents\devel\gradle-android-scala-plugin\sample\libproject\lib1\build\dex\test\debug C:\Users\foo\Documents\devel\gradle-android-scala-plugin\sample\libproject\lib1\build\classes\test\debug C:\Users\foo\Documents\devel\gradle-android-scala-plugin\sample\libproject\lib1\build\dependency-cache\test\debug C:\Users\foo\Documents\devel\gradle-android-scala-plugin\sample\libproject\lib1\build\pre-dexed\test\debug\classes-fafecd769c1dc1ab81a155943875ecd1881cb38c.jar C:\Users\foo\gradle-android-scala-plugin\sample\libproject\lib1\build\pre-dexed\test\debug\robotium-solo-5.0.1-67d752ee3c277876fb3e4772edfa6de4e19a452a.jar C:\Users\foo\Documents\devel\gradle-android-scala-plugin\sample\libproject\lib1\build\pre-dexed\test\debug\scala-library-2.10.3-81ddc8c8e9518c52eab8d8095a37a450032bf46a.jar C:\Users\foo\gradle-android-scala-plugin\sample\libproject\lib1\build\pre-dexed\test\debug\support-v4-19.0.1-9503e90b2fb1b6fd21967b2f4006bea2bf3713a9.jar
Error Code:
        2
Output:

        UNEXPECTED TOP-LEVEL EXCEPTION:
        java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
                at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
                at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
                at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
                at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
                at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
                at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
                at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
                at com.android.dx.command.dexer.Main.run(Main.java:230)
                at com.android.dx.command.dexer.Main.main(Main.java:199)
                at com.android.dx.command.Main.main(Main.java:103)


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 13.875 secs

Multidexing not working

I just cloned your sample, and put there many different libraries. Unfortunately it seems that multidex is not working because I get an error java.lang.ClassNotFoundException on path: DexPathList.

Everything works fine unless I exceed 65k methods in included libraries.

Enhancement | Enable removal of scala doc from scala library via plugin

Hi,

This is not a bug, but an enhancement information wrt Android Development. When the scala dependency is added to gradle build file: compile 'org.scala-lang:scala-library:2.11.6'

A lot of not needed files such as html documentation ends up in the apk making it bigger by 800k or more. The solution was to remove the scala folder in the apk by making use of these excludes given at the end.

However I do not know if I have exclude important files. My code works without those files.

I was wondering if you could add a feature to your plugin so that scala doc and other cruft does not end up in the final apk.

Also I thank you for your amazing work on this plugin. Thanks.

packagingOptions {
exclude 'scala'
exclude 'scala-async.properties'
exclude 'scala-parser-combinators.properties'
exclude 'scala-xml.properties'
exclude 'scala/tools'
exclude 'scala/tools/ant'
exclude 'scala/tools/ant/antlib.xml'
exclude 'scala/tools/ant/sabbus'
exclude 'scala/tools/ant/sabbus/antlib.xml'
exclude 'scala/tools/ant/templates'
exclude 'scala/tools/ant/templates/tool-unix.tmpl'
exclude 'scala/tools/ant/templates/tool-windows.tmpl'
exclude 'scala/tools/nsc'
exclude 'scala/tools/nsc/doc'
exclude 'scala/tools/nsc/doc/html'
exclude 'scala/tools/nsc/doc/html/resource'
exclude 'scala/tools/nsc/doc/html/resource/lib'
exclude 'scala/tools/nsc/doc/html/resource/lib/arrow-down.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/arrow-right.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/class.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/class_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/class_diagram.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/class_to_object_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/constructorsbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/conversionbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/defbg-blue.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/defbg-green.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/diagrams.css'
exclude 'scala/tools/nsc/doc/html/resource/lib/diagrams.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/filter_box_left.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/filter_box_left2.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/filter_box_right.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/filterbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/filterboxbarbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/filterboxbarbg.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/filterboxbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/fullcommenttopbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/index.css'
exclude 'scala/tools/nsc/doc/html/resource/lib/index.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/jquery-ui.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/jquery.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/jquery.layout.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/modernizr.custom.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/navigation-li-a.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/navigation-li.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object_diagram.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object_to_class_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object_to_trait_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/object_to_type_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/ownderbg2.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/ownerbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/ownerbg2.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/package.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/package_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/packagesbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/raphael-min.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/ref-index.css'
exclude 'scala/tools/nsc/doc/html/resource/lib/remove.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/scheduler.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected-implicits.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected-right-implicits.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected-right.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected2-right.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/selected2.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/signaturebg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/signaturebg2.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/template.css'
exclude 'scala/tools/nsc/doc/html/resource/lib/template.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/tools.tooltip.js'
exclude 'scala/tools/nsc/doc/html/resource/lib/trait.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/trait_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/trait_diagram.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/trait_to_object_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/type.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/type_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/type_diagram.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/type_to_object_big.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/typebg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/unselected.png'
exclude 'scala/tools/nsc/doc/html/resource/lib/valuemembersbg.gif'
exclude 'scala/tools/nsc/doc/html/resource/lib/versions.txt'
exclude 'scalac-plugin.xml'
exclude 'scaladoc.properties'
}

Unable to compile in Android Studio 1.1.0

This line throws an error resulting in the following message:

Error:No such property: bootClasspath for class: com.android.build.gradle.AppPlugin

This line breaks starting with Android Gradle Plugin version 1.1.0. Here's how the Groovy Android Plugin works around it: 1, 2, 3.

PSA: Exceptions in `Future` are hidden

    Future {
      throw new Exception
    }

This code does nothing at all, the app doesn't force close, and the error isn't even logged. As a workaround, you can do this:

    Future {
      throw new Exception
    }.onFailure { case e =>
      Log.w(Tag, "Error in future", e)
    }

I don't know if this can by fixed by the gradle plugin, but if not, you should probably use the workaround in your code.

DrawerLayout$LockMode not found

* What went wrong:
Execution failed for task ':app:compileDebugScala'.
> Class file for android.support.v4.widget.DrawerLayout$LockMode not found

This happens with dependency com.android.support:appcompat-v7:22.2.0. 22.1.0 works, though.

Scala: 2.11.6
Gradle: 2.2.1
Android Plugin: 1.1.3
compileSdkVersion: 22
buildToolsVersion: 22.0.1

Scala Library project

I have an Android library project, which is used by another Android Scala project.
I have added in the dependencies of the app, the custom lib.
When compiling, no Scala code is compiled. I know because the folder MyLib/build/classes is empty except for the BuildConfig.class.

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot"
        }
    }
    dependencies {
        // 0.8.3 con Gradle 1.10
        classpath 'com.android.tools.build:gradle:0.10.4'
        // https://github.com/saturday06/gradle-android-scala-plugin
        classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT'
    }
}

apply plugin: 'idea'
apply plugin: 'android-scala'
android {
    scala {
         addparams '-feature -target:jvm-1.7'
    }
    sourceSets {
        main {
            scala {
                srcDir "src/main/scala"
            }
        }
    }
}

My code is in MyLib/src/main/scala.
I consider this a bug in the plugin.

In a Scala Android app, the Scala code is compiled, but fails because of the absence of the compiled classes from my lib.

Compile Daemon

Is there any way to use the Scala compile daemon with this plugin? There's an option described here, but it doesn't work with this plugin.

On a related note, Android Studio does not seem to perform automatic builds either (all the boxes in Project Settings -> Compiler are checked).

DexIndexException, DexException

Hi,

Iโ€™m not very familiar with the plugin, but it seems that this would be the right place to ask about these exceptions (from https://groups.google.com/forum/#!topic/macroid/IIZ2iyie6h0):

This compiles fine in AndroidStudio but when I tried to run it (assembleDebug) I was getting the DexIndexException for too many methods. I tried enabling MultiDex (according to their wiki and android docs), but this just gave me a new exception:

DexException: Too many classes in --main-dex-list, main dex capacity exceeded

Problems with scala-compiler

Hi, i'm trying to use the interpreter from the scala-compiler library in one of my projects.
I started from one of your samples, and i manage to compile everything correctly.
However, when i test at runtime i got

D/AndroidRuntime( 2615): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 2615): CheckJNI is ON
E/memtrack( 2615): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug( 2615): failed to load memtrack module: -2
D/AndroidRuntime( 2615): Calling main entry com.android.commands.am.Am
I/ActivityManager( 1226): Force stopping jp.leafytree.android.hello appid=10057 user=0: start instr
I/ActivityManager( 1226): Start proc jp.leafytree.android.hello for added application jp.leafytree.android.hello: pid=2626 uid=10057 gids={50057, 9997} abi=x86
I/art     ( 2626): Not late-enabling -Xcheck:jni (already on)
I/MultiDex( 2626): VM with version 2.1.0 has multidex support
I/MultiDex( 2626): install
I/MultiDex( 2626): VM has multidex support, MultiDex support library is disabled.
I/MultiDex( 2626): install
I/MultiDex( 2626): VM has multidex support, MultiDex support library is disabled.
I/art     ( 2626): Rejecting re-init on previously-failed class java.lang.Class<scala.beans.ScalaBeanInfo>
I/art     ( 2626): Rejecting re-init on previously-failed class java.lang.Class<scala.beans.ScalaBeanInfo>
W/ClassPathPackageInfoSource( 2626): Cannot load class. Make sure it is in your apk. Class name: 'scala.beans.ScalaBeanInfo'. Message: scala.beans.ScalaBeanInfo
W/ClassPathPackageInfoSource( 2626): java.lang.ClassNotFoundException: scala.beans.ScalaBeanInfo
W/ClassPathPackageInfoSource( 2626):    at java.lang.Class.classForName(Native Method)
W/ClassPathPackageInfoSource( 2626):    at java.lang.Class.forName(Class.java:308)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
W/ClassPathPackageInfoSource( 2626):    at android.test.SimpleCache.get(SimpleCache.java:31)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
W/ClassPathPackageInfoSource( 2626):    at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
W/ClassPathPackageInfoSource( 2626):    at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
W/ClassPathPackageInfoSource( 2626):    at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
W/ClassPathPackageInfoSource( 2626):    at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:100)
W/ClassPathPackageInfoSource( 2626):    at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:367)
W/ClassPathPackageInfoSource( 2626):    at com.android.test.runner.MultiDexTestRunner.onCreate(MultiDexTestRunner.java:31)
W/ClassPathPackageInfoSource( 2626):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4509)
W/ClassPathPackageInfoSource( 2626):    at android.app.ActivityThread.access$1500(ActivityThread.java:144)
W/ClassPathPackageInfoSource( 2626):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
W/ClassPathPackageInfoSource( 2626):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/ClassPathPackageInfoSource( 2626):    at android.os.Looper.loop(Looper.java:135)
W/ClassPathPackageInfoSource( 2626):    at android.app.ActivityThread.main(ActivityThread.java:5221)
W/ClassPathPackageInfoSource( 2626):    at java.lang.reflect.Method.invoke(Native Method)
W/ClassPathPackageInfoSource( 2626):    at java.lang.reflect.Method.invoke(Method.java:372)
W/ClassPathPackageInfoSource( 2626):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
W/ClassPathPackageInfoSource( 2626):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
W/ClassPathPackageInfoSource( 2626): Caused by: java.lang.ClassNotFoundException: Didn't find class "scala.beans.ScalaBeanInfo" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/jp.leafytree.android.hello.test-1/base.apk", zip file "/data/app/jp.leafytree.android.hello-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
W/ClassPathPackageInfoSource( 2626):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W/ClassPathPackageInfoSource( 2626):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W/ClassPathPackageInfoSource( 2626):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
W/ClassPathPackageInfoSource( 2626):    ... 26 more
W/ClassPathPackageInfoSource( 2626):    Suppressed: java.lang.NoClassDefFoundError: scala.beans.ScalaBeanInfo
W/ClassPathPackageInfoSource( 2626):        at dalvik.system.DexFile.defineClassNative(Native Method)
W/ClassPathPackageInfoSource( 2626):        at dalvik.system.DexFile.defineClass(DexFile.java:226)
W/ClassPathPackageInfoSource( 2626):        at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
W/ClassPathPackageInfoSource( 2626):        at dalvik.system.DexPathList.findClass(DexPathList.java:321)
W/ClassPathPackageInfoSource( 2626):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
W/ClassPathPackageInfoSource( 2626):        ... 28 more
W/ClassPathPackageInfoSource( 2626):    Suppressed: java.lang.ClassNotFoundException: scala.beans.ScalaBeanInfo
W/ClassPathPackageInfoSource( 2626):        at java.lang.Class.classForName(Native Method)
W/ClassPathPackageInfoSource( 2626):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
W/ClassPathPackageInfoSource( 2626):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
W/ClassPathPackageInfoSource( 2626):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W/ClassPathPackageInfoSource( 2626):        ... 27 more

If you want to try out the repo is

https://github.com/algobardo/ATR

just clone and type

gradle connectedAndroidTest

When compiling mixed Scala/Java project, I get encoding problems

Even though, I've specified this (it should be the default anyway):

android {
    compileOptions.encoding = "UTF-8"
}

I get this warnings:

[ant:javac] /myproject/src/main/java/mypackage/MyClass.java:448: error: unmappable character for encoding ASCII

when doing this in a mixed Scala/Java project:

gradle compileDebugScala

It happens only with Java files.
Why is it trying to use ASCII encoding instead of UTF-8?

A "json4s" dependency causes a build failure

Adding a org.json4s:json4s-jackson_2.11:3.2.11 dependency results in

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':packageDebug'.
> Duplicate files copied in APK decoder.properties
    File 1: /Users/mojojojo/.gradle/caches/modules-2/files-2.1/org.scala-lang/scalap/2.11.0/4d1ef078a977e29c32d539fac2900ca56f17fb85/scalap-2.11.0.jar
    File 2: /Users/mojojojo/.gradle/caches/modules-2/files-2.1/org.scala-lang/scalap/2.11.0/4d1ef078a977e29c32d539fac2900ca56f17fb85/scalap-2.11.0.jar

`addparams` and `additionalParameters` do not work

I followed the *README * and added

scala {
    addparams "-deprecation"             // default: null
    additionalParameters "-deprecation"  // alias of addparams
}

But I got

Error:(44, 0) No signature of method: jp.leafytree.gradle.AndroidScalaPluginExtension.additionalParameters() is applicable for argument types: (java.lang.String) values: [-deprecation]

I guess the README file is outdated?

Gradle Android Scala Plugin fails due to trace files in generated source directory by Xtend in a multi language project

Hi, there is an issue when compiling multi language android projects where the scala zinc compiler tries to compile non scala stuff which fails.

The plugin seems to work with all JVM languages I have used in a sample project except for xtend which creates binary trace files on which the zinc compiler fails.

It would be nice if there would be an option to prevent zinc from compiling the whole project, ie compile only scala.

The work around was to add this to my gradle build file so that it would invoke the standalone ant task thus compile only scala:

tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = true
}

Feel free to request for more information if needed.

Support incremental compilation

Whenever I launch "gradle compileDebugScala", it seems to recompile everything.
I know it, because I see the same warnings again.

This isn't efficient.

Lint complains about unused resources

lint output

This seems to happen for all layout, string, xml and menu resources that are used only from scala.

Is there any better solution than completely ignoring the warning? (I'd still like to know about resources that are really missing)

Local jars as dependencies

I have the following line in my gradle build

compile fileTree(dir: 'libs', include: '*.jar')

which pulls local jars (from "libs" folder) as dependencies.

However, when I import packages from these jars, compilation fails. "Normal" maven dependencies work ok.

Could not resolve all dependencies for configuration

Hi!
Can me help with problem?

Could not resolve all dependencies for configuration ':app:_x1DebugCompile'.
Could not find org.scala-lang:scala-library:2.11.6.
Searched in the following locations:
file:/home/alexander/sdk/android/extras/android/m2repository/org/scala-lang/scala-library/2.11.6/scala-library-2.11.6.pom
file:/home/alexander/sdk/android/extras/android/m2repository/org/scala-lang/scala-library/2.11.6/scala-library-2.11.6.jar
file:/home/alexander/sdk/android/extras/google/m2repository/org/scala-lang/scala-library/2.11.6/scala-library-2.11.6.pom
file:/home/alexander/sdk/android/extras/google/m2repository/org/scala-lang/scala-library/2.11.6/scala-library-2.11.6.jar

I make project with command "gradle build"

Stability when

I've read this in the documentation:

Since it's still unstable and under development, please don't use it in production app.

I'm using it, and it works quite well.
What are the known problems?
Will it take long in order to consider it as stable?.

Android Annotation generated classes support

We have a project that uses classes autogenerated with android annotations and gradle.
If use the gradle build with android plugin only, some tricks on changing java classpath to add the generated source folder works fine. The same with android-scala plugin added fails, since the compilation starts with ant:scalac not ant:javac, and I can't figure out how to pass the same params to scala build or force javac build to run before scalac.

It seems in addition that I misconfigured the android-scala in the gradle.build too, since android { sourceSets { main { scala } }}} is not recognized at all.

Here is the snippets from the current gradle

// ----------- Build configuration
buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://saturday06.github.io/gradle-android-scala-plugin/repository/snapshot' }
        maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
    }
    dependencies {
        // Android plugin
        classpath 'com.android.tools.build:gradle:0.11.1'
        // android-apt plugin
        classpath 'com.neenbedankt.gradle.plugins:android-apt:+'//1.3
        // gradle-android-scala plugin
        classpath 'jp.leafytree.gradle:gradle-android-scala-plugin:1.0-SNAPSHOT'

    }
}

apply plugin: 'idea'
apply plugin: 'android'
apply plugin: 'android-apt'
// BREAK TO FIND OUT GENERATED CLASSES IF UNCOMMENT
// apply plugin: 'android-scala' 

// --------------- Android annotation plugin configuration

apt {
    arguments {
        androidManifestFile variant.processResources.manifestFile
        resourcePackageName "pan.enrollforecast.activity"
    }
}


// ----------- Android specific  configuration


android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'


    lintOptions {
          abortOnError false
    }


    def Properties versionProps = new Properties()
    versionProps.load(new FileInputStream(file('version.properties')))

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 19

        versionName versionProps['name']
        versionCode versionProps['code'].toInteger()
    }

    signingConfigs {
        release {
            def Properties localProps = new Properties()
            localProps.load(new FileInputStream(file('../local.properties')))
            def Properties keyProps = new Properties()
            assert localProps['keystore.props.file'];
            keyProps.load(new FileInputStream(file(localProps['keystore.props.file'])))
            storeFile file(keyProps["store"])
            keyAlias keyProps["alias"]
            storePassword keyProps["storePass"]
            keyPassword keyProps["pass"]
        }
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
            signingConfig signingConfigs.release
        }

        publicBeta.initWith(buildTypes.release)
        publicBeta {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
            versionNameSuffix " " + versionProps['betaNumber']
        }

        publicDebug.initWith(buildTypes.publicBeta)
        publicDebug {
            debuggable true
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-rules.txt')
            versionNameSuffix " Debug " + versionProps['betaNumber']

        }
    }

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            java.srcDirs = ['src/main/java' ]

            // SCALA PROP IS NOT  RECOGNIZED
           // scala {  
                //addparams '-feature -target:jvm-1.7'
            //    srcDir "src/main/scala"
            //}
            resources.srcDirs = ['src/main/resources']
            res.srcDirs = ['src/main/res']
            assets.srcDirs = ['src/main/assets']
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

def getSourceSetName(variant) {
    return new File(variant.dirName).getName();
}

// android annotation processing  
android.applicationVariants.all { variant ->
    aptOutput = file("${project.buildDir}/generated/source/apt/${variant.dirName}")

    def aptOutputDir = project.file("${project.buildDir}/generated/source/apt")

    basePackageName = "pan.enrollforecast.activity"
    println "****************************"
    println "variant: ${variant.name}"
    println "manifest:  ${variant.processResources.manifestFile}"
    println "aptOutput:  ${aptOutput}"
    println "****************************"

   //VARIANTS DON"T HAVE SCALACOMPILE METHOD
   // variant.scalaCompile.doFirst { // 
   //     println "*** compile scala doFirst ${variant.name}"
   // }
    variant.javaCompile.doFirst {
        println "*** compile doFirst ${variant.name}"
        aptOutput.mkdirs()
    }
    android.sourceSets[getSourceSetName(variant)].java.srcDirs += aptOutput.getPath()

   //SOURCESETS DOESNT HAVE SCALA PROP
    //android.sourceSets.scala.srcDirs += aptOutput.getPath()

    variant.javaCompile.source = variant.javaCompile.source.filter { p ->
        return !p.getPath().startsWith(aptOutputDir.getPath())
    }

    variant.javaCompile.options.compilerArgs += [
            '-processorpath', configurations.apt.getAsPath(),
            '-AandroidManifestFile=' + variant.processResources.manifestFile,
            '-AresourcePackageName=' + basePackageName,
            '-Atrace',
            '-s', aptOutput
    ]

}





// --------------- Dependencies
dependencies {
    apt "org.androidannotations:androidannotations:3.0.1"
    compile 'org.androidannotations:androidannotations-api:3.0.1'
    compile 'org.scala-lang:scala-library:2.10.4'
    compile 'com.android.support:appcompat-v7:19.1.+'
    compile 'com.android.support:gridlayout-v7:19.1.+'
    compile 'com.android.support:support-v4:19.1.+'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

Which build.gradle?

In ReadMe it says "build.gradle". Which one is it: for a whole module (in the root directory) or for a single project (in the directory of the project)?

Could not find property 'allJava' on source set android test.

Hi,

I am experiencing a weird issue with

./gradlew build --debug

in android studio 0.6 (http://tools.android.com/recent/androidstudio060released)


Gradle 1.12

Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_21 (Oracle Corporation 23.21-b01)
OS: Mac OS X 10.10 x86_64

19:07:39.215 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: groovy.lang.MissingPropertyException: Could not find property 'allJava' on source set android test.
19:07:39.216 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
19:07:39.216 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
19:07:39.217 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)
19:07:39.218 [ERROR] [org.gradle.BuildExceptionReporter]    at com.android.build.gradle.internal.api.DefaultAndroidSourceSet_Decorated.getProperty(Unknown Source)
19:07:39.219 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin$_updateAndroidSourceSetsExtension_closure13.doCall(AndroidScalaPlugin.groovy:302)
19:07:39.220 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin.updateAndroidSourceSetsExtension(AndroidScalaPlugin.groovy:295)
19:07:39.221 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin.apply(AndroidScalaPlugin.groovy:80)
19:07:39.221 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin$apply.callCurrent(Unknown Source)
19:07:39.222 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin.apply(AndroidScalaPlugin.groovy:119)
19:07:39.223 [ERROR] [org.gradle.BuildExceptionReporter]    at jp.leafytree.gradle.AndroidScalaPlugin.apply(AndroidScalaPlugin.groovy)
19:07:39.224 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:104)
19:07:39.225 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:68)
19:07:39.225 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:34)
19:07:39.226 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:116)
19:07:39.226 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)
19:07:39.227 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:85)
19:07:39.228 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:129)
19:07:39.229 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:41)
19:07:39.230 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.Project$apply.call(Unknown Source)

Improve Build Times?

Is there currently any way to use any of the methods to improve build time that other scala android libraries use? For instance installing the Scala library on a development device, and not including the scala library with debug builds so that it doesn't have to be compiled into the android APK?

Flavors support

I'm writing my project as a core library (with source code located in "src/main/scala") with the couple of flavors which intended to extend this library into the full apps. However, it seems that current snapshot version of plugin (as of September 2, 2014) doesn't support multi-flavored applications. When I build my app, it gets the default version of launch activity, which is located inside the "src/main/scala/path-to-main-activity", not the "src/flavor1/scala/path-to-main-activity".
I think this feature would be very useful.

The plugin cannot find my scala

My environment is Windows 7 64bit, scala 2.11. I have update my build.gradle file as indicated in the README file. When I run gradlew --debu I got the following error. Looks like it cannot find my scala. I tried to set the CLASSPATH environment variable, but doesn't help.

15:38:18.492 [ERROR] [org.gradle.BuildExceptionReporter]
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter]
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring project ':app'.
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter] > groovy.lang.MissingMethodException: No signature of method: java.net.URLClassLoader.close() is applicable for argument types: () values: []
Possible solutions: use([Ljava.lang.Object;), use(java.util.List, groovy.lang.Closure), use(java.lang.Class, groovy.lang.Closure), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)
15:38:18.493 [ERROR] [org.gradle.BuildExceptionReporter]
15:38:18.494 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:79)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:74)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:61)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:493)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:80)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
15:38:18.500 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
15:38:18.501 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
15:38:18.501 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
15:38:18.501 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
15:38:18.501 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
15:38:18.501 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
15:38:18.502 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.doAction(Main.java:46)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.Main.main(Main.java:37)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
15:38:18.503 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: java.net.URLClassLoader.close() is applicable for argument types: () values: []
Possible solutions: use([Ljava.lang.Object;), use(java.util.List, groovy.lang.Closure), use(java.lang.Class, groovy.lang.Closure), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at com.sun.proxy.$Proxy12.afterEvaluate(Unknown Source)
15:38:18.504 [ERROR] [org.gradle.BuildExceptionReporter]        at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        ... 29 more
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: groovy.lang.MissingMethodException: No signature of method: java.net.URLClassLoader.close() is applicable for argument types: () values: []
Possible solutions: use([Ljava.lang.Object;), use(java.util.List, groovy.lang.Closure), use(java.lang.Class, groovy.lang.Closure), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        at jp.leafytree.gradle.AndroidScalaPlugin.scalaVersionFromClasspath(AndroidScalaPlugin.groovy:269)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        at jp.leafytree.gradle.AndroidScalaPlugin$scalaVersionFromClasspath.callStatic(Unknown Source)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        at jp.leafytree.gradle.AndroidScalaPlugin.addAndroidScalaCompileTask(AndroidScalaPlugin.groovy:313)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        at jp.leafytree.gradle.AndroidScalaPlugin$_apply_closure1_closure17.doCall(AndroidScalaPlugin.groovy:88)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        at jp.leafytree.gradle.AndroidScalaPlugin$_apply_closure1.doCall(AndroidScalaPlugin.groovy:87)
15:38:18.505 [ERROR] [org.gradle.BuildExceptionReporter]        ... 36 more
15:38:18.508 [ERROR] [org.gradle.BuildExceptionReporter]
15:38:18.508 [LIFECYCLE] [org.gradle.BuildResultLogger]
15:38:18.509 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED

ViewCompat$LayoutDirectionMode not found

When i use compile 'com.android.support:support-v4:22.2.0'
or 'com.android.support:appcompat-v7:22.2.0'

Error:Execution failed for task ':mobile:compileDevDebugScala'.

Class file for android.support.v4.view.ViewCompat$LayoutDirectionMode not found

Zinc invokes scalac to compile java mistakenly or I misconfigured something?

Hi, I'm converting a sbt android project to use gradle android scala. The source code contains java and scala.

For my working repo

  1. Here's the link to the working branch: https://github.com/vmlinz/shadowsocks-android/tree/gradle-dev
  2. And the log for ./gradlew compileDebugJava --debug:https://gist.github.com/vmlinz/0438a7301a24ca820a49
  3. From what I can tell from the debug log, the zinc compiler is compiling one of the java files with scalac, which causes the error.

Experimenting repo

  1. My cloned repo: https://github.com/vmlinz/hello-scaloid-gradle, cloned from https://github.com/pocorall/hello-scaloid-gradle and add a directory of java sources.
  2. Log for the same command ./gradlew compileDebugJava --debug: https://gist.github.com/vmlinz/278b2ac854700f107bd6
  3. This time the compilation is correct

The only difference between build.gralde and build.sbt

sbt enable the user to set zinc compiling order to javaThenScala but in gradle I cannot find a place to set the zinc compiling order so it is forced Mixed as we can see in the log.

And I'm not sure if the the sourceset for java will only be compiled with javac as expected and the sourceset for scala will be compiled with only scalac.

Thanks for the reading.

Br,
Nick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.