Error when compiling Android
Asked Answered
A

4

0

Hello everyone,

I’m running Unity 4.6 in OS X 10.9.5, and I’m getting the following error when I try to compile to android:

Failed to compile resources with the following parameters:
-bootclasspath "/Users/ines/Development/android-sdk-macosx/platforms/android-21/android.jar" -d "/Users/ines/Documents/Game/Temp/StagingArea/bin/classes" -source 1.6 -target 1.6 -encoding UTF-8 "com/Company/Game/R.java" "com/facebook/android/R.java"
warning: java/lang/Object.class(java/lang:Object.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.

Does anyone know how I can solve this problem?

Athallia answered 6/6, 2023 at 1:56 Comment(2)

It's been a while since my problems with porting to Android, but make sure you've installed the 32-bit version of the java SDK and not the 64-bit. Can't say for sure it's still an issue, but several months ago this sidelined my Android development for a while.

Bullnose

Hey guys can someone please point me the way to do this on mac yosemite?

Flatiron
A
0

Thank you guys. I’ve found the solution.

Steps to make this work:

  1. Set the JAVA_HOME environment value:

export JAVA_HOME= ` /usr/libexec/java_home `

  1. Add the java bin folder to the PATH variable:

export PATH=$JAVA_HOME/bin:$PATH

  1. Create a link in the following directory:

sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents \ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

And that’s it. Hope it helps.

Athallia answered 6/6, 2023 at 1:58 Comment(5)

Thank you very much Nesokas!!! It worked like a charm to me!!

Rachellrachelle

I am using OSX 10.10 and JDK1.8.0_25. I had to use the command: 1- export JAVA_HOME=/usr/libexec/java_home -v 1.8 2- export PATH=$JAVA_HOME/bin:$PATH but at the 3rd step I get: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK: No such file or directory My error is because I updated the Android SDK... I guess I should target a specific folder that I am missing here. :~~

Kevakevan

Try locate the java home directory manually > open /Library try to navigate the folders until you find java home. Then copy the path and do: > export JAVA_HOME="path_you_copied" Hope you can solve it ;)

Athallia

Thank yooouuu, girl. You rock. I found the folder /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK, and yeah, the CurrentJDK link was pointing to 1.6.0 I manually made an alias of the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents as "CurrentJDK" and placed it /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK worked! :D Somehow terminal was not finding the folder. :~ Tnks, again. :~~ obs: cannot thumb up your answer because I have not enough reputation D:

Kevakevan

This really helped, thanks!

Sisely
F
0

It probably means Unity is running a Java compiler of some version and a JRE of a different (higher) version.

The compiler complains that it can only support version 50, but you are using version 51.

Check whether you have multiple Java installations on your machine, and the environment variables that you set.

Either leave only 1 installation, or make sure that Unity will use the correct JDK and JRE by setting the environment variables correctly.

Fourposter answered 22/10, 2014 at 6:9 Comment(5)

Starting from Android 5.0, Google requires Java 1.7. We are updating Unity requirements to match it (currently it is 1.6).

Walkthrough

What does that mean? I have all android platforms and tools installed (up to the latest 5.0). I am on Unity 4.5.4 is it compatible ?

Fourposter

It is. But as stated in http://unity3d.com/unity/system-requirements - you also need JDK installed. Now minimum requirement for JDK version is 1.7, you can check it by running "javac -version".

Walkthrough

I have JDK 1.8.0.25 installed. When building my Android project it fails for this error (compiler is 51). When i go to Android SDK and rename the folder platforms/android-21 to platforms/android-dont-21 it works fine.

Fourposter

I assume you double checked your JAVA_HOME and PATH variables, and ran the command I mentioned earlier. In this case please drop us an email with your editor log or submit a bug.

Walkthrough
A
0

Thank you guys. I’ve found the solution.

Steps to make this work:

  1. Set the JAVA_HOME environment value:

export JAVA_HOME= ` /usr/libexec/java_home `

  1. Add the java bin folder to the PATH variable:

export PATH=$JAVA_HOME/bin:$PATH

  1. Create a link in the following directory:

sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents \ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

And that’s it. Hope it helps.

Athallia answered 6/6, 2023 at 1:58 Comment(5)

Thank you very much Nesokas!!! It worked like a charm to me!!

Rachellrachelle

I am using OSX 10.10 and JDK1.8.0_25. I had to use the command: 1- export JAVA_HOME=/usr/libexec/java_home -v 1.8 2- export PATH=$JAVA_HOME/bin:$PATH but at the 3rd step I get: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK: No such file or directory My error is because I updated the Android SDK... I guess I should target a specific folder that I am missing here. :~~

Kevakevan

Try locate the java home directory manually > open /Library try to navigate the folders until you find java home. Then copy the path and do: > export JAVA_HOME="path_you_copied" Hope you can solve it ;)

Athallia

Thank yooouuu, girl. You rock. I found the folder /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK, and yeah, the CurrentJDK link was pointing to 1.6.0 I manually made an alias of the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents as "CurrentJDK" and placed it /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK worked! :D Somehow terminal was not finding the folder. :~ Tnks, again. :~~ obs: cannot thumb up your answer because I have not enough reputation D:

Kevakevan

This really helped, thanks!

Sisely
D
0

After upgrading my Android SDK version, I was having this error. I followed all the steps outlined for changing default Java version, environment, etc. I installed newest version of JDK (8), still nothing. I found that I needed to uninstall JDK 6 as final step to get everything to work again.

Daviddavida answered 31/10, 2014 at 21:43 Comment(0)
K
0

For people who doesn’t have new JDK version

  1. download JDK of mac os x : https://jdk8.java.net/download.html
  2. sudo ln -nsf /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/ /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
Kei answered 6/6, 2023 at 1:54 Comment(3)

Thank you very much. I've tried everything but nothing work. your idea help to solve my problem. thank you!

Gland

Thank you!

Piloting

Perfect solution! Thanks!!

Irreplaceable

© 2022 - 2024 — McMap. All rights reserved.