Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Default settings lead to java.lang.NoClassDefFoundError: ....R$layout #136

Open
scvalex opened this issue Aug 12, 2012 · 5 comments
Open

Comments

@scvalex
Copy link

scvalex commented Aug 12, 2012

Using Scala 2.9.2, sbt 0.12.0, and android-plugin from the tip of the repo, this happens:

Following the instructions in the Getting Started guide, the resulting project compiles, installs, but fails to start with the error:

08-12 11:30:03.129: E/AndroidRuntime(30468): java.lang.NoClassDefFoundError: org.abstractbinary.combien.R$layout

Adding the following to fullAndroidSettings in `Build.scala' seems to fix the problem:

 ++ Seq (
  compileOrder := CompileOrder.JavaThenScala
)

I haven't been able to figure out what's going on or why that change fixes it.

@scvalex
Copy link
Author

scvalex commented Aug 14, 2012

I think I've gotten to the bottom of this.

During build, there were a bunch of warnings like the following:

trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing org/abstractbinary/combien/R$layout.class
...while processing org/abstractbinary/combien/R$layout.class

Turns out it's the DEX compiler, dx, complaining that it can't understand Java 7 bytecode. The fix is to tell javac to output Java 6 bytecode:

javacOptions ++= Seq("-source", "1.6", "-target", "1.6"),

I think the problems now are:

  1. why was the above error treated like a warning,
  2. why did setting compileOrder seem to fix the issue.

@pligor
Copy link

pligor commented Sep 13, 2012

Hello scvalex! Many thanks for sharing. I get the exactly same problem
bad class file magic (cafebabe) or version (0033.0000)

I think your solution is close to the solutions of this stackoverflow: http://stackoverflow.com/questions/7866723/dx-bad-class-file-magic-cafebabe-or-version-0033-0000-with-adk14

but I still haven't been able to make it work!

Where do you exactly copy paste this line?
javacOptions ++= Seq("-source", "1.6", "-target", "1.6")
I tried inside the project/plugins.sbt
or inside Build.scala
but I didn't notice any difference...

You also mention: why did setting compileOrder seem to fix the issue
but how do you use it exactly?

Thank you!

@scvalex
Copy link
Author

scvalex commented Sep 13, 2012

Here's the Build.scala I'm using:

https://github.com/scvalex/combien/blob/master/project/Build.scala

I don't know why changing compileOrder seemed to fix the problem (it didn't, really).

@pligor
Copy link

pligor commented Sep 13, 2012

Hey thanks for the response!
Your case of Build.scala really fixed my problem with the warnings but now I get a different warning:
warning: [options] bootstrap class path not set in conjunction with -source 1.6

I'll keep on trying with your code in mind to see if I can make it work. Till now I only get the same thing. As soon as the Main Activity tries to start it crashes!

Anyway I am trying to create a How-To For Dummies on how to setup android + scala + intellij on ubuntu as for others to avoid spending (at least) two days hacking around with no luck as me!
I have uploaded this wiki on multiupload in case you could find some time to help!
Probably all the steps I have followed in this wiki are familiar to you. It's at the end that I am stuck...
So here is the link: http://www.multiupload.nl/DCDG7IFD5J

@scvalex
Copy link
Author

scvalex commented Sep 13, 2012

warning: [options] bootstrap class path not set in conjunction with
-source 1.6

I get that too, but it hasn't caused a problem yet.

As soon as the Main Activity tries to start it crashes!

My suggestion would be to check ddms for the exact error, but whatever it
is, it's not the issue reported here anymore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants