An easy-to-use sbt plugin for working with all Android projects

Related tags

Plugin sbt-android
Overview

Build Android Projects Using SBT

Build Status Latest version Join the chat at https://gitter.im/scala-android/sbt-android

http://scala-android.org/

Change log | FAQ

Auto-import from gradle using sbt-android-gradle

NOTE: 1.6.0 is the last version published using addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.6.0"), all future updates can be accessed by using addSbtPlugin("org.scala-android" % "sbt-android" % VERSION)

Demo

Description

This is an easy-to-use plugin for existing and newly created android projects. It requires SBT 0.13.8+

The plugin supports all android projects configurations. 3rd party libraries can be included by placing them in libs, or they can be added by using sbt's libraryDependencies feature. This build plugin is 100% compatible with the standard Android build system due to the use of the same underlying com.android.tools.build:builder implementation.

NOTE: proguard 5.1 does not like old versions of scala. Projects that wish to use Proguard 5.1 or newer with Scala should use scalaVersion := "2.11.5" or newer. For compatible scala projects and java-based projects which wish to use proguard 5.1 (to fix issues around generic types being removed from base-classes) a workaround is to add this setting into your build.sbt: proguardVersion := "5.1". See proguard bug #549 and SI-8931

NOTE: support-v4 22.2.x triggers compilation errors, see #173 and SI-7741

Support and Help

The first line of support is reading this README, beyond that, help can be found on the #sbt-android IRC channel on Freenode, or the scala-android/sbt-android gitter

Example projects

  • A growing collection of tests can be found under sbt-test/android-sdk-plugin/. These projects are examples of how to use the plugin in various configurations.
  • Testing the plugin can be run via sbt scripted, they require a device or emulator to be running in order to pass.
  • All tests have auto-generated build.properties and auto_plugins.sbt files that set the current version of sbt and the sbt-android to use for testing.

Usage

  1. Install sbt (from scala-sbt.org or use your local packaging system like macports, brew, etc.)

    • (OPTIONAL) Install the plugin globally by adding the following line in the file ~/.sbt/0.13/plugins/android.sbt:
    addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.7")
    
  2. Set the environment variable ANDROID_HOME pointing to the path where the Android SDK is installed. If ANDROID_HOME is not set, an Android SDK will be installed automatically at ~/.android/sbt/sdk. If any components are missing from your SDK, they will be installed automatically.

    • (OPTIONAL) Set ANDROID_NDK_HOME if NDK building is desired and an NDK already installed. If neither are set, or an NDK is not installed, an NDK will be installed to ~/.android/sbt/sdk/ndk-bundle automatically if an NDK build is detected (Android.mk and friends)
  3. (N/A if globally configured) Create a directory named project within your project and add the file project/plugins.sbt, in it, add the following line:

    addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.7")
    
  4. Create a new android project using gen-android if the plugin is installed globally

    • Instead of creating a new project, one can also do sbt gen-android-sbt to make sure everything is properly setup in an existing project.
  5. Create or edit the file named build.sbt and add the following line, (automatically performed if using gen-android) :

    enablePlugins(AndroidApp)
    
  6. (OPTIONAL) Select the target platform API you're building against in build.sbt, if not selected, the newest available will be selected automatically:

    // for Android 7.0, Nougat, API Level 24:
    platformTarget := "android-24"
    

    The Android Developer pages provides a list of applicable version codes.

  7. Now you will be able to run SBT, some available commands in sbt are:

    • compile
      • Compiles all the sources in the project, java and scala
      • Compile output is automatically processed through proguard if there are any Scala sources, otherwise; it can be enabled manually.
    • android:package-release
      • Builds a release APK and signs it with a release key if configured
    • android:package-debug
      • Builds a debug APK and signs it using the debug key
    • android:package
      • Builds an APK for the project of the last type selected, by default debug
    • android:test
      • run instrumented android unit tests
    • android:install
      • Install the application to device
    • android:run
      • Install and run the application on-device
    • android:uninstall
      • Uninstall the application from device
    • Any task can be repeated continuously whenever any source code changes by prefixing the command with a ~. ~ android:package-debug will continuously build a debug build any time one of the project's source files is modified.
  8. If you want sbt-android to automatically sign release packages add the following lines to local.properties (or any file.properties of your choice that you will not check in to source control):

    • key.alias: KEY-ALIAS
    • key.alias.password: PASSWORD (optional, defaults to key.store.password)
    • key.store: /path/to/your/.keystore
    • key.store.password: KEYSTORE-PASSWORD
    • key.store.type: pkcs12 (optional, defaults to jks)

Advanced Usage

  • IDE integration

    • The recommended IDE is IntelliJ, not Android Studio. However Android Studio can be used with some massaging (i.e install the Scala Plugin).
    • When loading a project into IntelliJ, it is required that the Android Support and Scala plugins are installed.
    • To ensure proper building, configure the IDE Run command to execute an SBT android:package task instead of Make (remove the make entry); this is found under Run Configurations.
    • The SBT plugin for IntelliJ is the one from orfjackal/idea-sbt-plugin.
    • The Scala plugin is still required for non-Scala projects in order to edit sbt build files from inside the IDE.
    • IntelliJ 14 and newer now includes native support for importing projects from sbt-android. The process generally works well, however there are still several caveats:
      • The idea-sbt-plugin is still required to actually perform the build
      • aar resources do not show up in editor or autocomplete automatically
        • They can be added manually, but must be added everytime the project is refreshed from SBT (SBT toolwindow -> Refresh)
        • To add:
          1. Project Structure -> Modules -> + -> Import Module
          2. $HOME/.android/sbt/exploded-aars/AAR-PACKAGE-FOLDER
          3. Create from existing sources
          4. Next all the until to the Finish button, finish.
          5. Go to the Dependencies tab for the Module you want to be able to access the AAR resources, click + -> Module Dependency
          6. Select the newly added AAR module above, and it will now be visible.
        • Steps 5 and 6 will need to be repeated any time the build description is refreshed (SBT toolwindow -> refresh)
        • This has been fixed by JetBrains/sbt-structure#42
          • Until it gets merged, can download sbt-structure-0.13.jar from the test case and place it into $HOME/.IntelliJVERSION/config/plugins/scala/launcher/sbt-structure-0.13.jar
  • Consuming apklib and aar artifacts from other projects

    • Optionally use apklib() or aar()
      • specifying apklib() and aar() is only necessary if the pom packaging for the dependency is not apklib or aar
    • libraryDependencies += aar("groupId" % "artifactId" % "version", "optionalArtifactFilename")
      • Basically, wrap the typical dependency specification with either apklib() or aar() to consume the library
      • If aars or apklibs are duplicately included in a multi-project build, specify transitiveAndroidLibs := false
      • apklib and aar that transitively depend on apklib and aar will automatically be processed. To disable set transitiveAndroidLibs := false
    • Sometimes library projects and apklibs will incorrectly bundle android-support-v4.jar, to rectify this, add this setting, repeat for any other incorrectly added jars:
      unmanagedJars in Compile ~= {
        _ filterNot (_.data.getName startsWith "android-support-v4")
      }
      
  • Using the google gms play-services aar:

    libraryDependencies +=
      "com.google.android.gms" % "play-services" % "VERSION"
    
  • Generating aar artifacts

    • To specify that your project will generate and publish either an aar artifact simply change the enablePlugins(AndroidApp) line to enablePlugins(AndroidLib)
  • Multi-project builds

    • See multi-project build examples in the test cases for an example of configuration.
    • All sub-projects in a multi-project build must specify exportJars := true. Android projects automatically set this variable.
    • When using multi-project builds in Scala, where library projects have scala code, but the main project(s) do(es) not, you will need to specify that proguard must run. To do this, the following must be set for each main project: proguardScala := true
  • Configuring sbt-android by editing build.sbt

    • Add configuration options according to the sbt style:
      • useProguard := true to enable proguard. Note: if you disable proguard for scala, you must specify uses-library on a pre-installed scala lib on-device or enable multi-dex.
    • Configurable keys can be discovered by typing android:<tab> at the sbt shell
  • Configuring proguard, some options are available

    • proguardOptions ++= Seq("-keep class com.foo.bar.Baz") - will tell proguard not to obfuscute nor optimize code (any valid proguard option is usable here)
  • proguardConfig ... can be used to replace the entire proguard config included with sbt-android

    • To allow obfuscation: proguardConfig -= "-dontobfuscate"
    • To allow optimization: proguardConfig -= "-dontoptimize"
  • On-device testing, use android:test and see Android Testing Fundamentals

  • Unit testing with robolectric and Junit (use the test task), see how it works in the robo-junit-test test case

    • Be sure to set fork in Test := true otherwise the classloading black magic in robolectric will fail.
  • Device Management

    • The commands devices and device are implemented. The former lists all connected devices. The latter command is for selecting a target device if there is more than one device. If there is more than one device, and no target is selected, all commands will execute against the first device in the list.
    • android:install, android:run and android:test are tasks that can be used to install, run and test the built apk on-device, respectively.
  • Full list of sbt-android added commands, all commands have full tab completion when possible.

    • adb-ls <path>
    • adb-cat <file>
    • adb-rm <file>
    • adb-pull <file> [destination]
    • adb-push <file> <destination>
    • adb-shell <command>
    • adb-runas <command>
    • adb-kill[/project]
    • logcat [-p pid] [-s tags] [options...]
    • logcat-grep [-p pid] [regex]
    • pidcat[/project] [partial pkg] [TAGs...]
    • pidcat-grep[/project] [partial pkg] [regex]
    • gen-android <package> <name>
    • gen-android-sbt
    • device <serial>
    • devices
    • adb-screenon
    • adb-wifi
    • adb-reboot [recovery|bootloader]
    • variant[/project] [buildType] [flavor]
    • variant-reset[/project]
    • android-install <package>
    • android-update <all|package>
    • android-license <license-id>

TODO / Known Issues

  • autolibs do not properly process aar resources. If anything in an autolib uses resources from such a library, the answer is to create a standard multi-project build configuration rather than utilize autolibs. autolibs can be disabled by manually configuring localProjects
  • androidTest cannot be written in scala if one wants to use junit4 annotations. a workaround is possible if setting minSdkVersion to 21 is ok. With minSdk set to 21, also set dexMulti := true and useProguardInDebug := false to bypass proguard. This will allow junit4 tests written in scala to function.
Comments
  • Problem with proguard cache?

    Problem with proguard cache?

    It seems to me that the proguard cache is not used correctly in the plug-in.

    If I generate my app with clean and then android:install, then everything works ok. Proguard is executed, the app is installed and runs without problems.

    However, if I leave out the clean and I don't change any code (e.g. I just change something in xml files), then proguard is not executed again, but the dex file is regenerated nevertheless without using proguard and apparently without including the scala library.

    This is the output:

    [info] [debug] cache hit, skipping proguard!
    [info] [debug] Forcing clean dex
    [info] Generating classes.dex
    [info] Packaged: guidemate-debug-unaligned.apk (2,64MB)
    [info] Debug package does not need signing: guidemate-debug-unaligned.apk
    [info] zipaligned: guidemate-debug.apk
    [info] Installing...
    [info] [guidemate-debug.apk] Install finished: 2,64MB in 17,17s. 157,37KB/s
    

    In tasks.scala (proguardTaskDef), there is this part:

    if (inputs.proguardCache exists (_.exists)) {
        s.log.info("[debug] cache hit, skipping proguard!")
        None
    }  
    

    I think the problem could be that None is returned here instead of the cached jar file.

    opened by migo 30
  • Support for android:extractNativeLibs?

    Support for android:extractNativeLibs?

    When I set it to false, it compiles but when the device tries to install the app, this error pops out: INSTALL_FAILED_INVALID_APK.

    On N emulator: INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2.

    Or am I doing anything wrong?

    opened by Mygod 28
  • Predex files collision in a multiproject setup

    Predex files collision in a multiproject setup

    Having these preconditions

    • multiproject
    • multi-dex enabled
    • predex cache in place

    Changing anything in project library and do run results in exception

    java.lang.IllegalArgumentException: Source predex-libraries/classes-fea1db6a2e85fdeda8f2073688c847728e688fa4.jar/classes.dex 
    and destination predex-libraries/classes-fea1db6a2e85fdeda8f2073688c847728e688fa4.jar/classes.dex must be different
    

    See full showcase https://github.com/aafa/sbt-multiproject

    Interestingly, doing reload + run (both each time) can make it work but not for long - I'm getting OutOfMemory exception after a while.

    opened by aafa 23
  • NoClassDefFoundError when using anonymous functions

    NoClassDefFoundError when using anonymous functions

    If I have a simple Activity that uses anonymous functions:

    class MyActivity extends Activity with ViewFinder {
      override def onCreate(savedInstanceState: Bundle) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.main)
    
        val y = { (x: Int) => x + 1 }
    
        Log.i("foo", y(4).toString)
      }
    }
    

    my app crashes with :

    01-04 23:47:52.853    1942-1942/com.example.Test D/AndroidRuntime﹕ Shutting down VM
    01-04 23:47:52.853    1942-1942/com.example.Test W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2cfdb08)
    01-04 23:47:52.933    1942-1942/com.example.Test E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.example.Test, PID: 1942
        java.lang.NoClassDefFoundError: com.example.Test.MyActivity$$anonfun$1
                at com.example.Test.MyActivity.onCreate(MyActivity.scala:38)
                at android.app.Activity.performCreate(Activity.java:5243)
                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
                at android.app.ActivityThread.access$700(ActivityThread.java:135)
                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
                at android.os.Handler.dispatchMessage(Handler.java:102)
                at android.os.Looper.loop(Looper.java:137)
                at android.app.ActivityThread.main(ActivityThread.java:4998)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:515)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
                at dalvik.system.NativeStart.main(Native Method)
    
    opened by moreindirection 23
  • From time to time Proguard is not activated

    From time to time Proguard is not activated

    Hi,

    Your plugin is awesome but sometimes, without any reason it doesn't work.

    Sometimes, when I launch the compilation, I get a crash from SBT telling me that I have more than 65K methods.

    Then I type clean in the console, retry and it just works. Next compilation works, and so on for several hours, and for no obvious reason, the same error comes back. I make no modification to the sbt file or anything like this. It just kind of random (or there is a cause I have not yet found).

    Moreover I have a huge proguard file. I know it s applied automatically (when proguard is used) because otherwise I would get lots of warnings.

    Here is my plugin sbt file

    addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.2.2")
    
    addSbtPlugin("com.hanhuy.sbt" % "sbt-idea" % "1.6.0")
    
    addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.2")
    

    and here is my build.sbt file

    // so we can use keywords from Android, such as 'Android' and 'proguardOptions'
    import android.Keys._
    import android.Dependencies.{aar,apklib}
    
    // load the android plugin into the build
    android.Plugin.androidBuild
    
    
    // project name, completely optional
    name := "OBackup"
    
    // pick the version of scala you want to use
    scalaVersion := "2.10.2"
    
    // scala 2.10 flag for feature warnings
    scalacOptions in Compile += "-feature"
    
    // for non-ant-based projects, you'll need this for the specific build target:
    platformTarget in Android := "android-19"
    
    resolvers ++= Seq("Bugsense repository" at "http://www.bugsense.com/gradle/",
      "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/",
      "Mandubian repository snapshots" at "https://github.com/mandubian/mandubian-mvn/raw/master/snapshots/",
      "Mandubian repository releases" at "https://github.com/mandubian/mandubian-mvn/raw/master/releases/"
    )
    
    libraryDependencies ++= Seq (
      "org.scaloid" %% "scaloid" % "latest.integration",
      "com.netflix.rxjava" % "rxjava-core" % "latest.integration",
      "com.netflix.rxjava" % "rxjava-scala" % "latest.integration" intransitive(),
      "com.netflix.rxjava" % "rxjava-android" % "latest.integration" intransitive(),
      "com.android.support" % "support-v4" % "19.0.0",
      "com.google.code.gson" % "gson" % "latest.integration",
      "org.joda" % "joda-convert" % "1.5",
      "joda-time" % "joda-time" % "2.3",
      "com.googlecode.json-simple" % "json-simple" % "1.1" intransitive(),
      "de.keyboardsurfer.android.widget" % "crouton" % "latest.integration" intransitive(),
      "com.bugsense.trace" % "bugsense" % "3.5",
      "com.google.android.gms" % "play-services" % "latest.integration" intransitive(),
      "com.google.apis" % "google-api-services-drive" % "latest.integration" intransitive(),
      "com.google.api-client" % "google-api-client" % "latest.integration" intransitive(),
      "com.google.api-client" % "google-api-client-android" % "latest.integration"  intransitive(),
      "com.google.http-client" % "google-http-client-jackson" % "latest.integration" intransitive(),
      "com.google.http-client" % "google-http-client-gson" % "latest.integration" intransitive(),
      "com.typesafe.play" %% "play-json" % "2.2.0"
    )
    
    ideaExcludeFolders ++= Seq (
        ".idea",
        ".idea_modules",
        "target",
        "project"
    )
    
    proguardCache in Android ++= Seq(
      ProguardCache("org.scaloid") % "org.scaloid" %% "scaloid",
      ProguardCache("rx") % "com.netflix.rxjava" %% "rxjava-core",
      ProguardCache("rx") % "com.netflix.rxjava" %% "rxjava-scala",
      ProguardCache("rx") % "com.netflix.rxjava" %% "rxjava-android",
      ProguardCache("play") % "play" %% "play-json"
    )
    
    
    // call install and run without having to prefix with android:
    run <<= run in Android
    
    install <<= install in Android
    

    Do you have an idea about the reason?

    Regards

    opened by pommedeterresautee 21
  • Incremental=false using multiDex

    Incremental=false using multiDex

    We are using android-sdk-plugin in a new Android project.

    In order to avoid 65K methods error, we have set up our project to use a multidex configuration and we have disabled the proguardCache, setting proguardCache in Android := Seq.empty

    Here more info about our config:

    proguardScala in Android := true,
    useProguard in Android := true,
    proguardCache in Android := Seq.empty
    
    ....
    
    dexMaxHeap in Android := "2048m",
    dexMulti in Android := true,
    dexMinimizeMainFile in Android := true,
    dexMainFileClasses in Android := multiDexClasses
    

    Since we use multiDex, incremental=false is always shown in console and the compilation time is too long.

    Are we missing anything in our config for using multiDex with incremental?

    Thanks!

    opened by franciscodr 18
  • Race condition is back?

    Race condition is back?

    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.x" on path: ...

    I'm using 1.6.6 and it seems this old exception is back. It occurs ~50% of the times when launching apps. And when that happens I have to do a clean and rebuild which is annoying.

    opened by Mygod 17
  • Dex crash

    Dex crash

    Hi,

    I’m trying your plugin on the Macroid sample project: https://github.com/stanch/macroid-starter

    Here’s my build.sbt: https://github.com/stanch/macroid-starter/blob/master/build.sbt

    When android:run is performed for the first time, everything is fine. However, on subsequent invocations this is what happens:

    [trace] Stack trace suppressed: run last android:dex for the full output.
    [error] (android:dex) com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    [error]         C:\Progra~2\Android\android-sdk\build-tools\17.0.0\dx.bat -JXmx1024m --dex --incremental --no-strict --output C:\projects\macroid-starter\target\android-bin\classes.d
    ex C:\Users\stanch\.ivy2\cache\com.android.support\support-v13\jars\support-v13-13.0.0.jar C:\Users\stanch\.ivy2\cache\com.scalarx\scalarx_2.10\jars\scalarx_2.10-0.1.jar C:\Users\sta
    nch\.ivy2\cache\com.typesafe.akka\akka-actor_2.10\bundles\akka-actor_2.10-2.1.2.jar C:\Users\stanch\.ivy2\cache\io.dylemma\scala-frp_2.10\jars\scala-frp_2.10-1.0.jar C:\Users\stanch\
    .ivy2\cache\org.scalaz\scalaz-core_2.10\bundles\scalaz-core_2.10-7.0.3.jar C:\projects\macroid-starter\target\android-bin\classes.jar C:\Users\stanch\.ivy2\cache\com.typesafe\config\
    bundles\config-1.0.0.jar C:\Users\stanch\.ivy2\cache\com.android.support\support-v4\jars\support-v4-13.0.0.jar C:\projects\macroid-starter\target\scala-2.10\cache\default-42a471\glob
    al\proguard_cache\proguard-cache-cdb4ee70ce1e1c206e16ebf6f9bc6f5db317c704.jar
    [error] Error Code:
    [error]         1
    [error] Output:
    [error]
    [error]         UNEXPECTED TOP-LEVEL EXCEPTION:
    [error]         java.lang.IllegalArgumentException: already added: Lorg/macroid/starter/MainActivity$$anon$1$$anonfun$1;
    [error]                 at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
    [error]                 at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
    [error]                 at com.android.dx.command.dexer.Main.processClass(Main.java:490)
    [error]                 at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
    [error]                 at com.android.dx.command.dexer.Main.access$400(Main.java:67)
    [error]                 at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
    [error]                 at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
    [error]                 at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
    [error]                 at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
    [error]                 at com.android.dx.command.dexer.Main.processOne(Main.java:422)
    [error]                 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
    [error]                 at com.android.dx.command.dexer.Main.run(Main.java:209)
    [error]                 at com.android.dx.command.dexer.Main.main(Main.java:174)
    [error]                 at com.android.dx.command.Main.main(Main.java:91)
    [error]         1 error; aborting
    [error] Total time: 17 s, completed 29.09.2013 4:14:12
    

    Could you take a look?

    opened by stanch 17
  • Can not launch javacv with scala sbt plugin

    Can not launch javacv with scala sbt plugin

    Hi, A simple app with android-sdk-plugin works fine. The problems start when trying to add javacv (bindings to opencv). Below is given my sbt file. At first try I was able to install the app on device but it crashed with AndroidRuntime(20677): java.lang.NoClassDefFoundError: org.bytedeco.javacpp.opencv_core$Rect. After this I can not install the app at all and Proguard is barking (1500 lines worth of complaints). Any ideas? Can the problem be related to "maven-plugin"?

    import android.Keys._
    
    android.Plugin.androidBuild
    
    platformTarget in Android := "android-16"
    
    scalaVersion := "2.11.6"
    
    classpathTypes += "maven-plugin"
    
    libraryDependencies ++= Seq(
      "org.bytedeco"                 % "javacpp"         % "0.11",
      "org.bytedeco"                 % "javacv"          % "0.11",
      "org.bytedeco.javacpp-presets" % "opencv" % ("2.4.11-0.11") classifier "",
      "org.bytedeco.javacpp-presets" % "opencv" % ("2.4.11-0.11") classifier "android-arm"
    )
    
    name := "hello-world"
    
    javacOptions in Compile ++= Seq("-source", "1.7", "-target", "1.7")
    '''
    
    opened by AurimasAnskaitis 16
  • Support libs are now AARs

    Support libs are now AARs

    Both support-v4 and support-v13, since version 20.0.0. What a pity! I am not sure, but this code will probably have to be modified.

    There is also another problem: in Macroid I was happily including the dependencies the simple way:

    libraryDependencies ++= Seq(
      "com.google.android" % "android" % "4.1.1.4" % "provided",
      "com.android.support" % "support-v13" % "19.1.0"
    )
    

    Now that I have to unpack the AAR, it would make more sense to just use the plugin. However I don’t rely on resource ids, don’t have an AndroidManifest.xml, don’t want to publish as AAR instead of plain Scala library. Do you think I actually should? Or would it be possible to include the plugin without all that and just use aar to extract the jar from the AAR?

    opened by stanch 16
  • Could not find class 'scala.Some'

    Could not find class 'scala.Some'

    Trying to build a Android project with a Android library and a Android project. Both containing scala code.

    I have followed this https://gist.github.com/pfn/5872770 and created this Build.scala

    import sbt._ import sbt.Keys._

    import android.Keys._

    object MyProjectBuild extends Build {

    // meta project lazy val root = Project(id = "ABM", base = file(".")) settings(Seq( packageT in Compile <<= packageT in Android in ABM, packageRelease <<= packageRelease in Android in ABM, packageDebug <<= packageDebug in Android in ABM, run <<= run in Android in ABM ) ++ android.Plugin.androidCommands: _* ) aggregate(ABM, GR)

    // android application project lazy val ABM = Project(id = "Custom", base = file("ABM")) settings( android.Plugin.androidBuild(GR) ++ Seq( proguardScala in Android := true, proguardOptions in Android ++= Seq( "-dontobfuscate", "-dontoptimize" ) ): _*) dependsOn GR

    val GenericRace = Project(id = "GR", base = file("GR")) settings ( Seq( scalacOptions in Compile += "-deprecation", javacOptions in Compile += "-deprecation", libraryDependencies ++= Seq(/* "com.viewpagerindicator" % "library" % "2.4.1" % "provided", "com.android.support" % "support-v4" % "18.0.0", "com.android.support" % "appcompat-v7" % "18.0.0"_/) ) ++ android.Plugin.androidBuild: __) }

    But whenever i run the application on a device i get Class not found exception

    Could not find class 'scala.Some' or java.lang.NoClassDefFoundError: scala.concurrent.ExecutionContext

    These files are not in the classes.dex.

    opened by hkirk 16
  • Getting error while trying to build .AAR file

    Getting error while trying to build .AAR file

    I'm trying to build .aar file with sbt but I'm getting this error:

    [error] Not a valid key: package-release (similar: package-name, set-release, packageName)
    [error] android:package-release
    [error]  
    

    I already changed

    enablePlugins(AndroidApp) line to enablePlugins(AndroidLib) but still get this error.

    To build aar I'm using sbt clean android:package-release command.

    How can I fix this?

    opened by hmmmk 0
  • Scala 3 support?

    Scala 3 support?

    Is there any chance that someone could look into supporting scala 3 projects with sbt-android?

    Starting with the sbt-android example projects, and adding addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.0") and scalaVersion := "3.0.0-M3" I haven't been able to get this to work yet.

    Has anyone been able to do this successfully yet? Is there more migration work that needs to be done to make this plugin support scala 3?

    opened by Sintrastes 3
  • Upgrade to sbt 1

    Upgrade to sbt 1

    Upgrade the build to sbt 1.2.8 in order to support the release of an sbt 1.x version of this plugin.

    Bump the version to 2.0.0-SNAPSHOT and remove most things deprecated in the 1.x releases of the plugin.

    Parallelize build across scripted tests so build time on Travis isn't pushing the 50 minute limit.

    Huge props to @soc for doing a bunch of work to get this started.

    opened by jeffboutotte 20
Owner
Scala on Android
Scala on Android
A Gradle Plugin that removes unused resources in Android projects.

#Lint Cleaner Plugin Removes unused resources reported by Android lint including strings, colors and dimensions. Depracated As of Android Studio 2.0+

Marco RS 705 Nov 25, 2022
A Leiningen plugin for building Clojure/Android projects

lein-droid A Leiningen plugin to simplify Clojure development for Android platform. It acts as a build-tool for Clojure/Android projects. Usage First

Clojure/Android 643 Dec 15, 2022
Jetbrains plugin for differentiating opened projects by color!

?? ?? Project-Color ?? ?? Remember your projects by color! Colorize the title bar to differentiate your open projects. Working on multiple projects si

yon 25 Dec 16, 2022
An Eclipse builder for Android projects using Scala

OBSOLETE This is an Eclipse plugin for the obsolete Android Eclipse development system, and isn't relevant for modern Scala on Android. OVERVIEW Andro

James Moore 136 Nov 25, 2022
Export BlueJ project archives from Gradle projects.

bluej-jar Gradle Plugin This is a Gradle plugin for producing JAR files which are valid BlueJ project archives. This plugin only works in Java project

KCL UG 5 Apr 7, 2022
Development environment for methodic projects

Methodic Super Project Get started developing faster! This superproject helps you get started building on the Methodic platform by providing a single

null 1 Mar 24, 2022
gradle-android-scala-plugin adds scala language support to official gradle android plugin

gradle-android-scala-plugin gradle-android-scala-plugin adds scala language support to official gradle android plugin. See also sample projects at htt

saturday06 345 Dec 10, 2022
eventbus-intellij-plugin 3.8 0.0 L1 Java Plugin to navigate between events posted by EventBus.

eventbus-intellij-plugin Plugin to navigate between events posted by EventBus. Post to onEvent and onEvent to Post Install There are two ways. Prefere

Shinnosuke Kugimiya 315 Aug 8, 2022
IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea

IntelliJ Idea Astor Plugin IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea. It communicates with a local/remote program

null 4 Aug 28, 2021
Intellij-platform-plugin-template - IntelliJ Platform Plugin Template

IntelliJ Platform Plugin Template TL;DR: Click the Use this template button and

null 0 Jan 1, 2022
BuildPlots-Plugin - PaperMC-Plugin for build contests written in Kotlin.

BuildPlotsPlugin PaperMC-Plugin for build contests. This is my first time using Kotlin and the first plugin I've written after a long time. It is stil

Lukas Heinzl 0 Jan 1, 2022
K6-intellij-plugin - IntelliJ-based Plugin to run k6 tests locally or in the k6 Cloud from your IntelliJ IDE

IntelliJ-based Plugin to run k6 tests locally or in the k6 Cloud from your Intel

Mikhail Bolotov 8 Jan 2, 2023
Ownership-gradle-plugin - Gradle code ownership verification plugin

Gradle code ownership verification plugin A gradle plugin that will verify owner

null 4 Dec 15, 2022
plugin to use to replace text in android studio

replace-text-plugin Template ToDo list Create a new IntelliJ Platform Plugin Template project. Get known with the template documentation. Verify the p

null 1 Nov 29, 2022
Gradle plugin to use git tags as project version names

Version Name Gradle Plugin This plugin adds a kotlin extension function that provides a version name based on the latest git tag. How to use it ?? App

Doist 3 Mar 9, 2022
Gradle plugin to help use create project

Infra-Gradle-Plugin 该插件旨在简化 Gradle 项目配置,几行代码就可以迅速开始一个项目, 仅支持 Kotlin DSL, Groovy 未测试! 引入插件 plugins { id("com.labijie.infra") version "your version"

Red Sparrow 0 Dec 23, 2021
Social share - Social Sharing Plugin For Private Use only (Code without error checking)

Flutter Social Share plugin for sharing file to media with multiple (More option

MP IT SPACE 0 Mar 19, 2022
Kotlin compiler plugin generates support synthetic methods for use SaveStateHandle without constants and string variables.

SavedState Compiler Plugin Kotlin compiler plugin generates support methods for use SaveStateHandle without constants and string variables. Example If

Anton Nazarov 3 Sep 20, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022