Unable to convert classes into dex format. NEED HELP

Hi all, i’ve just finished to create my first android game, and i’m getting this error when i try to build with the Unity Ads Service turend on. That’s is real borning! 2 Months to finish the game and i’m get this issue :frowning:

So i’ve simple enabled the unity Ads service and create just 2 scripts

This for Initializer

 using UnityEngine;
using UnityEngine.Advertisements;
public class UnityAdsInitializer : MonoBehaviour
{
    [SerializeField]
    private string
        androidGameId = "17564",
        iosGameId = "17569";

    [SerializeField]
    private bool testMode;

    void Start()
    {
        string gameId = null;

#if UNITY_ANDROID
        gameId = androidGameId;
#elif UNITY_IOS
        gameId = iosGameId;
#endif

        if (Advertisement.isSupported && !Advertisement.isInitialized)
        {
            Advertisement.Initialize(gameId, testMode);
        }
    }

and this to show ads if show ad button is pressed

 using UnityEngine;
using UnityEngine.Advertisements;
using System.Collections;

public class PlayAd : MonoBehaviour {



    void Awake()
    {

        if(Advertisement.isSupported)
        {
            Advertisement.Initialize("1095237", false);
        }


    }

    public void ShowAd()
    {
        if(Advertisement.IsReady() )
        {
            Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleAdResult});
        }
    }

	private void HandleAdResult(ShowResult result)
    {
        switch (result)
        {
            case ShowResult.Finished:
                Debug.Log("Player Has Watch All Ad");
            break;
            case ShowResult.Skipped:
                Debug.Log("Player Has Skipped The Ad");
            break;
            case ShowResult.Failed:
                Debug.Log("Player Has Failed To Launch App");
            break;
        }
    }
}

Now when i try to build i’m getting this soo bad error:

 Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:/Program Files (x86)/Java/jdk1.7.0_79\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="C:/Users/Mattia/AppData/Local/Android/sdk\tools" -Dfile.encoding=UTF8 -jar "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar" -

stderr[
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:274)
	at SDKMain.main(SDKMain.java:127)
]
stdout[

]

I really need help, cause i’m stuck on this error from alredy 4 days… Thanks in advice

I feel your pain as I just went through this exact thing on Android. Firstly delete every trace of the Unity Ads plugin in your project, check theres nothing in standard assets too plus your plugins and editor folder. Then delete your Advertisement initialisation code as you don’t need this if you have enabled the service in the editor. Then finally I think you need a higher java SDK or NDK I’m not sure which but install 1.8 then change the editor external tool preferences to us this new one. Then try again.

3 Likes

Hi and thanks for the fast response, i try now, thanks.
Can you give me a link pls? I’ve founded this: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html it is ok?

yes thats the one. take one for your OS from the top selection.

2 Likes

Amazing! It works now! Thanks man, you’ve saved me!!

I just wish I’d been around to help me a week ago! it might have saved me 3 wasted days of hitting my head on a wall.

Yeah, ahah, me too!

Only another question XD
The statistic of my project on UnityAds site will update only if the game is on Google Play? I mean, if i install the APK in my device by usb cable and the app isn’t on Google Play Store i will se the statistic increase? Cause i’ve try it, but the statistic say
Ad starts
0
0
0

Unfortunately the Unity Ads system is very little understood, I’ve never seen my stats increase when the app is in test mode and even now when it’s released some days I get no hits and other days I do see some stats.

1 Like

Ok, i’m only mean, how i’m sure then when i see the ads it the ads really seen for my account? The initialization is automatic? Man really, thanks for all! :smile:

Maaaaaaaaaaaan thanks so much! saved my day dude!