Incerteza
Incerteza

Reputation: 34884

How to debug sbt's failure "java.lang.NumberFormatException: For input string: "android-4"" upon loading Android project?

I have an android project written in Scala and java using sbt 0.12.4. When I try to load it by sbt, I get an error:

$ sbt
[info] Loading project definition from /Users/alex/Documents/projects/android/test2/my_project/project
[error] java.lang.NumberFormatException: For input string: "android-4"
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

I searched for the string android-4 but didn't find anything similar to it at all. And no other clues either.

How do I find out where the error is? Or rather, how do I debug it?

last doesn't help:

Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? last
[info] Loading project definition from /Users/alex/Documents/projects/android/test2/my_project/project
[debug] Running task... Cancelable: false, check cycles: false
[debug] 
[debug] Initial source changes: 
[debug]   removed:Set()
[debug]   added: Set()
[debug]   modified: Set()
[debug] Removed products: Set()
[debug] Modified external sources: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set()
[debug] 
[debug] Sources indirectly invalidated by:
[debug]   product: Set()
[debug]   binary dep: Set()
[debug]   external source: Set()
[debug] All initially invalidated sources: Set()
[debug] Copy resource mappings: 
[debug]   
java.lang.NumberFormatException: For input string: "android-4"
  at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
  at java.lang.Integer.parseInt(Integer.java:449)
  at java.lang.Integer.parseInt(Integer.java:499)
  at scala.collection.immutable.StringLike$class.toInt(StringLike.scala:231)
  at scala.collection.immutable.StringOps.toInt(StringOps.scala:31)
  at sbtandroid.AndroidPath$$anonfun$sbtandroid$AndroidPath$$determineBuildToolsVersion$2$$anonfun$2.apply(AndroidPath.scala:22)
  at sbtandroid.AndroidPath$$anonfun$sbtandroid$AndroidPath$$determineBuildToolsVersion$2$$anonfun$2.apply(AndroidPath.scala:22)
  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
  at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
  at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
  at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:38)
  at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
  at scala.collection.mutable.ArrayOps.map(ArrayOps.scala:38)
  at sbtandroid.AndroidPath$$anonfun$sbtandroid$AndroidPath$$determineBuildToolsVersion$2.apply(AndroidPath.scala:22)
  at sbtandroid.AndroidPath$$anonfun$sbtandroid$AndroidPath$$determineBuildToolsVersion$2.apply(AndroidPath.scala:18)
  at scala.collection.IndexedSeqOptimized$class.foldl(IndexedSeqOptimized.scala:52)
  at scala.collection.IndexedSeqOptimized$class.reduceLeft(IndexedSeqOptimized.scala:69)
  at scala.collection.mutable.ArrayOps.reduceLeft(ArrayOps.scala:38)
  at sbtandroid.AndroidPath$.sbtandroid$AndroidPath$$determineBuildToolsVersion(AndroidPath.scala:18)
  at sbtandroid.AndroidPath$$anonfun$settings$5.apply(AndroidPath.scala:40)
  at sbtandroid.AndroidPath$$anonfun$settings$5.apply(AndroidPath.scala:40)
  at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
  at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
  at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$single$1.apply(INode.scala:159)
  at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$single$1.apply(INode.scala:159)
  at sbt.EvaluateSettings$MixedNode.evaluate0(INode.scala:177)
  at sbt.EvaluateSettings$INode.evaluate(INode.scala:132)
  at sbt.EvaluateSettings$$anonfun$sbt$EvaluateSettings$$submitEvaluate$1.apply$mcV$sp(INode.scala:64)
  at sbt.EvaluateSettings.sbt$EvaluateSettings$$run0(INode.scala:73)
  at sbt.EvaluateSettings$$anon$3.run(INode.scala:69)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
  at java.lang.Thread.run(Thread.java:695)
[error] java.lang.NumberFormatException: For input string: "android-4"
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

UPDATE:

enter image description here

Upvotes: 0

Views: 1132

Answers (1)

johanandren
johanandren

Reputation: 11479

The stack trace you get when you use last mentions AndroidPath.scala:22 so I'd check the source of tha. The message of the exception says that the string android-4 is not a number, so something in the android sbt plugin you are using thinks that a string containing that should contain only digits.

Search through your build config (and maybe project directories) after the string android-4 and replace it with something that is a number and see if that helps.

If that does not help: Look at the sources of the android plugin at the specified line to see what it is doing and you may figure it out (I couldn't as I don't know what plugin and version of it you are using). You could also start sbt in debug mode and add a breakpoint in the AndroidPath sources.

Upvotes: 1

Related Questions