3

I ported my app from Eclipse to Android Studio, and now my app won't run. Just to be clear, I did not export from Eclipse. I created a new project in Android Studio, and manually cut/pasted every class in my project.

I am running Android Studio on a new Macbook Pro - Yosemite. I am having some issues running my app, even though it compiles. From what I can see, my problem might be that I am using JDK 1.8. Well, I cannot figure out how the heck to get JDK 6.

Here is the error I get when I run the project in Android Studio

Error:Execution failed for task ':app:preDexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

When I scroll up in the Gradle Event Log, I see this error:

com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)

In addition to the app not running, Android Studio freezes a lot! Again, is this because of the version of Java I have installed?

essedbl
  • 520
  • 1
  • 7
  • 19

2 Answers2

0

Wait, why didn't you IMPORT the project using Android Studio? It will build the gradle files for you.

enter image description here

Choose New/Import Project...

Then you will see it will let you just point to the root directory of your eclipse project:

enter image description here

Rob
  • 11,446
  • 7
  • 39
  • 57
  • I tried that several times. I was running Eclipse Kepler with ADT on my Linux Laptop. But, I cannot find an ADT bundle for Mac anymore, so I just decided to move to Android Studio since Google is kinda pushing that. When I imported the project, I had all kinds of challenges. So I said forget it, I will create the project as brand new. That way, I don't have to worry about Legacy structures getting in the way. – essedbl Mar 28 '15 at 17:52
  • It's not JDK 1.8, I have been using that with Gradle/Android studio for a long time. – Rob Mar 28 '15 at 17:54
  • Although bad class file magic sure sounds like a JDK issue. You are on the mac which makes going between versions more problematic, since that's turned into a total mess. You could use Homebrew to do that and then try it. Also, you probably know this, but there is the JDK you are running AS with and the JDK that is set on the project. For sure you can use 1.8 for either. – Rob Mar 28 '15 at 17:55
  • Wait, doesn't this thread: http://stackoverflow.com/questions/24662801/bad-class-file-magic-or-version answer this? – Rob Mar 28 '15 at 17:57
  • no, that post didn't help. I have tried fiddling with the SDK definition. I find it odd, I have JDK 8 installed, but in the Module Settings, I can only choose 1.6 or 1.7 for the source/target compatibility – essedbl Mar 28 '15 at 18:26
  • I am going to install JDK 7. Maybe that will help – essedbl Mar 28 '15 at 18:31
  • 1
    There is no support for 1.8 in Android is the reason for that. – Rob Mar 28 '15 at 18:34
  • I finally gave in to Tor Norbye's argument here: http://stackoverflow.com/questions/24124911/cant-run-android-studio-on-yosemite and installed 1.6 just for running Android Studio, but my project is using JDK 8. – Rob Mar 28 '15 at 18:36
  • I looked for 1.6, but I couldn't find it. Lol. – essedbl Mar 28 '15 at 18:46
  • 1
    You have to get that one from Apple. That's one of the reasons Java is such a mess on Mac: stewardship reverted to Oracle after 1.6. – Rob Mar 28 '15 at 18:54
0

Ok, installing JDK 7 fixed the issue. So, this Macbook is brand new, running Yosemite. It didn't have a JDK installed already. When I ran Android Studio, it said no JVM found. So, I went and got the latest from Oracle. So the only JDK I had was JDK 8.

So, for whatever reason, installing JDK 7 has made it so my app will actually run... Whoo Hoo! I'm back in business.

essedbl
  • 520
  • 1
  • 7
  • 19