Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

UnityAds don't compile

Discussion in 'Unity Ads' started by acropole, Dec 14, 2014.

  1. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    151
    Hi,

    I've just installed 4.6.0f3 and downloaded unityads from asset store and I get this error :

    Assets/Standard Assets/UnityAds/Scripts/Advertisements/PictureAds/PictureAdsRequestsManager.cs(92,48): error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'
     
  2. unity-nikkolai

    unity-nikkolai

    Unity Technologies

    Joined:
    Sep 18, 2014
    Posts:
    541
    Sounds like your build platform might be currently set to webplayer. Make sure that your build platform is set to either Android or iOS. Select File > Build Settings. Then select either of the two platforms and select Switch Platform.

    The appropriate fix for this issue is to wrap the C# scripts included in this package with conditional compilation statements. We'll have to do this in the next update.
     
  3. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    151
    It solves the problem, thx. But there is a new one :

    Failed to compile resources with the following parameters:
    -bootclasspath "C:/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-21\android.jar" -d "C:\Users\cédrik\Documents\unity\Boonsy\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "com\unity3d\ads\android\R.java" "com\w77\Boonsy\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.
    1 warning

    UnityEditor.HostView:OnGUI()

    Unity version : 4.6.1f1
    adt updated 2 1 2015
     
  4. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    151
    Error building Player: Win32Exception: ApplicationName='javac.exe', CommandLine='-bootclasspath "C:/adt-bundle-windows-x86_64-20131030/sdk/platforms/android-21\android.jar" -d "C:\Users\cédrik\Documents\unity\Boonsy\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "com\unity3d\ads\android\R.java" "com\w77\Boonsy\R.java"', CurrentDirectory='C:\Users\cédrik\Documents\unity\Boonsy\Temp\StagingArea\gen'
     
  5. matthewdjw

    matthewdjw

    Joined:
    Jun 17, 2014
    Posts:
    6
    You need to go to your "My Computer" right click and select properties advanced settings then environment variables. Add JAVA_HOME to user and set it to your jdk location, you need JDK I suggest the newest one. Also add PATH add it to the jdk/bin; folder remember the semi colon. If you don't get it working tell me and I should be able to help I had the same issue, just on my phone right now so can't give screenshots

    Edit :

    Never mind I'm going to go to the computer and show you.

    Right click on My Computer and go to properties.


    Select advanced system settings.


    Set JAVA_HOME and PATH like mine but change the jdk version based off which one you have installed.


    Same with the PATH in system variables.

    Hope this helps!
     
  6. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    151
    Thanks.
    Solutions I've found on the web talk about JDK_HOME. Google is definitly not my friend.
     
  7. SemiLethal

    SemiLethal

    Joined:
    Jan 16, 2015
    Posts:
    1
    Is there any ETA on when this may get included? It's a pain to have to add/remove the package to switch from testing modile to web.
     
  8. unity-nikkolai

    unity-nikkolai

    Unity Technologies

    Joined:
    Sep 18, 2014
    Posts:
    541
    I'm sorry, I don't have an ETA. We are working towards an update but, it's at least a month out from now.

    The fix for this is relatively simple though:
    Code (CSharp):
    1. // For each script in the Unity Ads asset package
    2. // Insert the following line as the first line of the script:
    3. #if UNITY_IOS || UNITY_ANDROID
    4.  
    5. //*** KEEP CONTENTS OF UNITY ADS SCRIPT HERE ***
    6.  
    7. // Then add the following line as the last line in the script:
    8. #endif
    Keep in mind that anywhere you reference the Unity Ads code in your own scripts, you will need to wrap it with the same compiler conditional statements as well.

    This helper script for example, the using directive should be commented out as well as anything out side of public variables. By leaving the public variables outside the bounds of the conditional statement, you'll be able to retain the values set via the inspector when you change between platforms.
     
    Last edited: Jan 16, 2015
  9. p3dart-es

    p3dart-es

    Joined:
    May 24, 2013
    Posts:
    197
    I want to note that the problem is with Unity and JDK 32 bits version (seems that the new Unity 4.6.1p5 version will fix it).

    I had this problem, and I finally solved it installing JDK 64 bits version, and setting only the JAVA_HOME variable to the 64 bits path "C:\Program Files\Java\jdk1.8.0_31". I didn´t need to set up the other two PATH variables (in my case).

    Regards.
     
    unity-nikkolai likes this.
  10. acropole

    acropole

    Joined:
    Aug 13, 2009
    Posts:
    151
    It don't compile with a blank project set to build webplayer with unityad imported from asset store but not used : Only one empty scene + unityads ->
    Assets/Standard Assets/UnityAds/Scripts/Advertisements/PictureAds/PictureAdsRequestsManager.cs(92,48): error CS0117: `System.IO.File' does not contain a definition for `WriteAllBytes'

    But it does if build platform is set to standalone.