game won't build after importing unity ads

after importing unity ads, the game will play fine in the editor, even loading the default dummy ad for testing, but will not build. gives error:
Error building Player: Win32Exception: ApplicationName=‘C:\Program Files (x86)\Java\jre1.8.0_20\bin\javac.exe’, CommandLine=‘-bootclasspath “C:/Users/C/Android SDK/sdk/platforms/android-20\android.jar” -d “C:\Users\C\Documents\MyGame\Temp\StagingArea\bin\classes” -source 1.6 -target 1.6 -encoding UTF-8 “com\unity3d\ads\android\R.java” “com\unity3d\tester\R.java”’, CurrentDirectory=‘C:\Users\C\Documents\MyGame\Temp\StagingArea\gen’

i have even deleted the game objects containing the ad scripts and still get error. cannot continue working on the project unless i delete all unity ads objects, but hoping there is a fix before i have to resort to that.

EDIT: deleted all unity ads folders and objects and game builds fine, so there is def. a problem with unity ads and android

Exact same problem here!

Also i get the exact same error when trying to use Chartboost

I have a feeling that this might be caused by duplicate .jar files, but I could be wrong.

Try searching for all jar files and delete any duplicates. Sometimes different plugins import the same jar files.

Hmm, the mention of “game objects with ad scripts” is throwing a red flag for me. Are you using the latest version of the Unity Ads asset package? Before importing the new package, first delete the old package assets from your project.

Could you try it again with a fresh import of the asset package?

If you’re interested, here’s a link to the demo script I use to make sure everything works:
https://gist.github.com/wcoastsands/3d003528a76f94fa2ede

Let me know how it works out for you guys.

it was a fresh import from whatever asset was live in the unity store as of this morning. no old packages to delete. as for the GO’s, they were just buttons that referenced and turned on/off the ads. the scripts aren’t the problem as they play fine, the error occurs during build and is some kind of conflict with the android SDK.

EDIT: just reimported it again and made a build before touching anything after import and got the build error.

Thanks, for the info. Still trying to reproduce the issue here. What other packages are you using?

the only *.jar files in my entire project are from unity ads. nothing else has that kind of build access to the SDK.

Getting the same error on my side. I’ll try to get an answer for you guys here soon.

Thanks for the heads up!

Hi guys!

Noticed this line on the error message:

…C:\Program Files (x86)\Java**\jre1.8.0_20**bin\javac.exe…

It seems that Unity is trying to build with Java Runtime Environment, and not with Android SDK.

Please check out this:

If you already have Android SDK setup, and still get this error make sure that Unity is actually using the correct path:

– (shameless copy & paste) –
4. Add the Android SDK path to Unity
The first time you build a project for Android (or if Unity later fails to locate the SDK) you will be asked to locate the folder where you installed the Android SDK (you should select the root folder of the SDK installation). The location of the Android SDK can also be changed in the editor by selecting Unity > Preferences from the menu and then clicking on External Tools in the preferences window.

i have been building android games for a year now and this only became a problem when i imported unity ads and goes away immediately when i remove it, so that is not the issue, but ty.

however, it does use the JRE because unity ads is built into a .jar file.

Ok, thanks for the info.

And changing the path had no effect?

I’ll bump investigating this up in priority.

Cheers,
Heikki

however, if unity ads were looking for the JRE in the wrong location (i dont remember having an option to set it) or were erroneously using the JRE instead of the android SDK (and i have no inner knowledge of how the two communicate), then that could be the issue.

EDIT: in fact that IS the issue. there is no file by that name. no javac.exe. the java compiler is javacpl.exe. Good eyes, Heikki!

Just one clarification, so that I don’t misunderstand:

  1. You were able to build the same project to android before you used the ads-plugin?
  2. With the ads plugin the same project gave the error message?
  3. When you removed the ads plugin it compiled again?

Heikki

yes to all 3.

the ads plugin is looking for a file that does not exist. there is no javac.exe. the java compiler is javacpl.exe

EDIT: not the compiler, but nonetheless there is no javac.exe file

So, I was reproducing this issue. I checked the system PATH, which was missing the path to the JDK bin directory.

Added the following to PATH and was able to build without the error:
C:\Program Files\Java\jdk1.8.0_20\bin

Can you confirm?

1 Like

Well that is weird,

There is no compiler (and shouldn’t be) on JRE. The “javacpl.exe” is Java control panel and doesn’t really help with compiling :wink: http://www.java.com/en/download/help/win_controlpanel.xml

Just importing the plugin shouldn’t change what is used to build your game.

Could you check where your JAVA_HOME environment variable points to?

there was no PATH variable, so i create one that points to the java bin directory. however, it is still looking for a file that does not exist. there is no javac.exe:

ApplicationName=‘C:\Program Files (x86)\Java\jre1.8.0_20\bin**\javac.exe’,**

What happens if you point it to the Android SDK’s bin directory?

That should definitely have the javac.

upon googling this, there is a difference between the JRE and JDK. javac.exe does not exist in the JRE, only in the JDK: