Unity: All versions | Appodeal SDK: All versions


The following exception on SDK initialization in the logs happens if Appodeal dependency has not been imported in the mainTemplate.gradle file.

AndroidJavaException: java.lang.ClassNotFoundException: com.appodeal.ads.Appodeal
08-05 17:56:52.361 17621 19642 E Unity : java.lang.ClassNotFoundException: com.appodeal.ads.Appodeal
08-05 17:56:52.361 17621 19642 E Unity : at java.lang.Class.classForName(Native Method)
08-05 17:56:52.361 17621 19642 E Unity : at java.lang.Class.forName(Class.java:454)
08-05 17:56:52.361 17621 19642 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
08-05 17:56:52.361 17621 19642 E Unity : at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
08-05 17:56:52.361 17621 19642 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
08-05 17:56:52.361 17621 19642 E Unity : at android.os.Handler.dispatchMessage(Handler.java:102)
08-05 17:56:52.361 17621 19642 E Unity : at android.os.Looper.loop(Looper.java:246)
08-05 17:56:52.361 17621 19642 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
08-05 17:56:52.361 17621 19642 E Unity : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.appodeal.ads.Appodeal" on path: DexPathList[[zip file "/data/app/~~LZ2ZUoy1wx6uO6K32tjtVg==/com.appodeal.test-c2MK2vNy6WEMOqDgbY_VSQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~LZ2ZUoy1wx6uO6K32tjtVg==/com.appodeal.test-c2MK2vNy6WEMOqDgbY_VSQ==/lib/arm, /data/app/~~LZ2ZUoy1wx6uO6K32tjtVg==/com.appodeal.test-c2MK2vNy6WEM
To fix it complete the following steps from Android configuration section to resolve Appodeal's dependencies: 

1. After the import Appodeal Unity Plugin, in the Unity editor select File → Build Settings → Android.

2. Add flag Custom Gradle Template for Unity 2017.4 - Unity 2019.2 versions or Custom Main Gradle Template for Unity 2019.3 or higher (Build Settings → Player Settings → Publishing settings).

3. Enable the setting "Patch mainTemplate.gradle" (Assets → External Dependency Manager → Android Resolver → Settings).

4. Enable the setting "Use Jetifier" (Assets → External Dependency Manager → Android Resolver → Settings).

5. Then run Assets → External Dependency Manager → Android Resolver and press Resolve or Force Resolve.

6. As a result, the modules, that are required for the Appodeal SDK support, will be imported to project's mainTemplate.gradle file.