jberkel / android-plugin

An sbt plugin for Android development in Scala
https://groups.google.com/forum/#!forum/scala-on-android
Other
476 stars 113 forks source link

Building code with annotations+java constants #43

Open jberkel opened 13 years ago

jberkel commented 13 years ago

When adding annotation to a scala class which refer to java constants you get the following error:

App.scala:9: annotation argument needs to be a constant; found: R.string.crash_notif_ticker_text
[error]             resNotifTickerText = R.string.crash_notif_ticker_text,

This is related to https://issues.scala-lang.org/browse/SI-2764. A workaround for now is to add the following to the project definition:

override def compileOrder = CompileOrder.JavaThenScala

We could make this the default for the plugin, but it will slow things down.

DavidPerezIngeniero commented 10 years ago

I'm affected by this problem.

Here is an excerpt of the problem:

import org.acra.{ACRA, ReportingInteractionMode}
import org.acra.annotation.ReportsCrashes

 @ReportsCrashes(
formKey = "",
formUri = "http://...",
httpMethod = HttpSender.Method.PUT, reportType = HttpSender.Type.JSON,
formUriBasicAuthLogin = "myuser", formUriBasicAuthPassword = "mypassword",
mode = ReportingInteractionMode.TOAST, forceCloseDialogAfterToast = false, resToastText = R.id.problem
)
class AplicacionInc extends android.app.Application {
}

The error I get is this:

Error:(22, 92) annotation argument needs to be a constant; found: R.id.problem
mode = ReportingInteractionMode.TOAST, forceCloseDialogAfterToast = false, resToastText = R.id.problem

Creating a val for "R.id.problem" doesn't help.