安卓统一游戏中的java InMobi集成错误
我正在尝试将InMobi集成到我的unity游戏中以显示广告。我制作了一个jar库,并通过unity中的JNI调用了所需的方法,但出现以下错误:
Android Java Exception: java.lang.NoClassDefFoundError
我的方法是静态的,因为unity不能为我执行Call()
,所以我只能执行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 楼答案
来自InMobi的Sohan
看起来您正试图在Unity中直接使用本机SDK。InMobi有一个Unity插件,你可以使用它。该插件充当本机SDK和应用程序之间的中介
您可以查看此link以了解进一步的集成详细信息