Tuesday, October 16, 2012

sbt: pushing and pulling from a local Nexus installation

Here's a simple build.sbt for pushing and pulling from a local Nexus repository.  The Nexus repository has almost no configuration changes; I've added a password for the deployment user (here given as "deploy"), but other than that it's running with the settings that came out of the box.  Note that the hostname in my case is "git", and Nexus uses the default port of 8081.


name := "fnord"

organization := "com.restphone"

version := "0.1-SNAPSHOT"

scalaVersion := "2.10.0-RC1"

// Compile for these Scala versions
crossScalaVersions := Seq("2.9.1", "2.9.2", "2.10.0-RC1")

publishMavenStyle := true

scalaSource in Compile <<= baseDirectory(_ / "src")

resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/snapshots"

resolvers += "Sonatype OSS Snapshots" at "http://git:8081/nexus/content/repositories/releases"

libraryDependencies ++= Seq(
  "com.restphone" % "artifactname" % "1.0"
)

publishTo <<= version { (v: String) =>
  val nexus = "http://git:8081/nexus/content/repositories/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "snapshots")
  else
    Some("releases" at nexus + "releases")
}

credentials += Credentials("Sonatype Nexus Repository Manager", 
                           "git", 
                           "deployment",
                           "deploy")

Sunday, August 19, 2012

Looks like switching to zfs was worth doing:


pool: jamespool
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://zfsonlinux.org/msg/ZFS-8000-9P
 scan: scrub repaired 0 in 29h13m with 0 errors on Fri Aug 17 13:12:16 2012
config:

        NAME                                                 STATE     READ WRITE CKSUM
        jamespool                                            ONLINE       0     0     0
          mirror-0                                           ONLINE       0     0     0
            scsi-SATA_WDC_WD7500AACS-_WD-WCAU47125177        ONLINE       0     0     0
            scsi-SATA_WDC_WD7500AACS-_WD-WCAU47162708        ONLINE       0     0     0
          mirror-1                                           ONLINE       0     0     0
            scsi-SATA_WDC_WD7500AAKS-_WD-WCAPT0622481        ONLINE       0     0     0
            scsi-SATA_ST3000DM001-9YN_S1F01R75-part1         ONLINE       0     0     0
          mirror-2                                           ONLINE       0     0     0
            scsi-SATA_WDC_WD7500AAKS-_WD-WCAPT0622515        ONLINE       0     0     0
            scsi-SATA_ST3000DM001-9YN_S1F01R75-part2         ONLINE       0     0     0
          mirror-3                                           ONLINE       0     0     0
            scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350-part1  ONLINE       0     0 3.50K
            scsi-SATA_ST3000DM001-9YN_S1F01R75-part3         ONLINE       0     0     0
          mirror-4                                           ONLINE       0     0     0
            scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350-part2  ONLINE       0     0   429
            scsi-SATA_ST3000DM001-9YN_S1F01R75-part4         ONLINE       0     0     0

SMART isn't seeing a problem with scsi-SATA_WDC_WD15EARS-00_WD-WMAVU2129350 yet though.

Friday, August 10, 2012

OpenSL ES for Android - SL_RESULT_CONTENT_UNSUPPORTED

If you're getting a SL_RESULT_CONTENT_UNSUPPORTED result from OpenSL like this:

E/AudioRecord( 2108): AudioFlinger could not create record track, status: -1
E/libOpenSLES( 2108): android_audioRecorder_realize(0x1cde560) error creating AudioRecord object
W/libOpenSLES( 2108): Leaving Object::Realize (SL_RESULT_CONTENT_UNSUPPORTED)

look a bit higher in the log. The solution might be staring you in the face:

W/ServiceManager(   81): Permission failure: android.permission.RECORD_AUDIO from uid=10078 pid=2108
E/AudioFlinger(   81): Request requires android.permission.RECORD_AUDIO

Tuesday, July 24, 2012

scalaz for the Eclipse Scala IDE plugin

There's a brand new build of scalaz 6.0.4 for M5 that seems to work well with the Eclipse plugin.  If you were having issues before with scalaz + Eclipse, give this one a shot:

    <dependency>
      <groupId>org.scalaz</groupId>
      <artifactId>scalaz-core_2.10.0-M5</artifactId>
      <version>6.0.4</version>
    <dependency>

Saturday, July 14, 2012

Scala on Android: what you need to know (some of this applies to any large Android codebase)

Here's a collection of all of the interesting links talking about issues with Scala running on Android.  (And note that it's not specific to Scala; it's large codebases generally.)

Summary

Android tools limit you to 65535 methods referenced, which includes both methods defined and methods called.  If you hit this limit (and you will with anything past hello-world when you're using the Scala library), you need to run an external tool.

If you use Eclipse, try my AndroidProguardScala plugin.

If you use sbt, use the sbt Android plugin.

Useful links

http://code.google.com/p/android/issues/detail?id=7147 Issue 7147: dx fails on scala-library.jar and scala-compiler.jar
The Android bug.  Important quote:
It turns out that you have made the first report we've seen of anyone running into Dalvik's existing limit of 
65536 method references per dex file
https://issues.scala-lang.org/browse/SI-5278 Scala outputs redundant interface declarations in bytecode
This is the bug + fix that should solve LinnearAlloc issues.

http://code.google.com/p/android/issues/detail?id=22586 Issue 22586: Dexopt fails with "LinearAlloc exceeded" for deep interface hierarchies
Earlier Scala versions hit this, but the problem has been solved by SI-5278.

https://issues.scala-lang.org/browse/SI-4620 Android install of scala 2.9.0 built binary fails (worked with scala 2.8.1)
Here's the Scala issue covering the Scala patch that reduced the

https://github.com/scala/scala/commit/7a99c03da1d31ac5950eecb30f422f43c5e3d04e Don't generate redundant interfaces
Here's the Scala patch itself.  It includes this comment:
Drop redundant interfaces (ones which are implemented by some
other parent) from the immediate parents. This is important on
android because there is otherwise an interface explosion.
http://code.google.com/p/android/issues/detail?id=20814 dx crashes on projects with > 65,535 methods
Note that the title is misleading (it's not just number of methods).  From the bug:
As I understand it, the limit is the number of methods referenced, which includes both methods defined and methods called, which is why you might see this even if your app only contains 56,484 method definitions.
http://www.scala-lang.org/node/10929
A conversation about using Scala with Android

Thursday, July 12, 2012

Getting this? E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xb

Seeing this in your Android code?

E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xb

Make sure you're not:

a) Calling back into java from javascript in a WebView, and then b) Dereferencing a null pointer in Java.

Notice that this problem has nothing to do with any of your JNI code.

Thursday, July 5, 2012

Parsing Java signatures with Scala's parser combinators

I need to parse some Java signatures for a new version of the AndroidProguardScala plugin. I had read about #Scala parser combinators, but never used them. Here's what I came up with for parsing Java signatures (the things like Ljava/util/List<[Ljava/util/List<Ljava/lang/String;>;>; that you see when you're using asm and other tools).




And here's the test file:

New version of the Android/Scala Eclipse plugin available

I released a new version (41) of the AndroidProguardScala Eclipse plugin making it easier to run #Scala code on #Android. This one fixes a few bugs and should work nicely with the latest ADT. Available here.

Using maven just to fetch dependencies, not to build

There are lots of useful things about maven, but I needed to just fetch some dependencies. Here's how:



Run mvn dependency:copy-dependencies and you'll end up with your dependencies in your ./libs directory.