InMobi intergration in Unity game error for android

707 views Asked by At

I'm trying to integrate InMobi into my unity game to show ads. I made a jar library and call needed method via JNI in unity but getting the following error:

Android Java Exception: java.lang.NoClassDefFoundError‏

My method is static because unity doesn't do Call() for me, so I can do only CallStatic().

public static void ShowInMobi(final Context context)
 {

  //com.google.ads.mediation.inmobi.InMobiAdapter.disableHardwareAcceleration();

  //((Activity) context).runOnUiThread(new Runnable() {
       //     public void run() {
   String CLASS_TO_LOAD ="com.inmobi.commons.InMobi";


   try 
   {

       Class<?> newClass = Class.forName(CLASS_TO_LOAD);
       System.out.println("Class "+newClass+" found successfully!");
   } 
   catch (ClassNotFoundException ex) 
   {
       ex.printStackTrace();
       System.out.println("Class "+CLASS_TO_LOAD+" not found!");
   } 
   catch (Throwable any) 
   {                          
       System.out.println("Unexpected error! "+any);
   }

          if(interstitialInMobi==null)
          {                            
               com.inmobi.commons.InMobi.initialize((Activity) context, "my_ad_unit_id");

           interstitialInMobi = new IMInterstitial((Activity) context, "my_ad_unit_id");
           interstitialInMobi.loadInterstitial();

          }
          else
          {
               if (interstitialInMobi.getState() == IMInterstitial.State.READY){
               interstitialInMobi.show();
               interstitialInMobi.loadInterstitial();
          }
  }

        //}
  //});
1

There are 1 answers

0
Sohan On

Sohan from InMobi here

Looks like you are trying to use the native SDK directly in Unity. InMobi has a Unity plugin that you can use instead. The plugin acts as the mediator between the native SDK and your app.

You can check this link for further integration details.