Java android统一游戏中的InMobi集成错误
我正在尝试将InMobi集成到我的unity游戏中以显示广告。我制作了一个jar库,并通过unity中的JNI调用了所需的方法,但出现以下错误: Android Java异常:Java.lang.NoClassDefFoundError 我的方法是静态的,因为unity不能为我执行Java android统一游戏中的InMobi集成错误,java,android,java-native-interface,unity3d,inmobi,Java,Android,Java Native Interface,Unity3d,Inmobi,我正在尝试将InMobi集成到我的unity游戏中以显示广告。我制作了一个jar库,并通过unity中的JNI调用了所需的方法,但出现以下错误: Android Java异常:Java.lang.NoClassDefFoundError 我的方法是静态的,因为unity不能为我执行Call(),所以我只能执行CallStatic() publicstaticvoidshowinmobi(最终上下文) { //com.google.ads.mediation.inmobi.InMobiAdapt
Call()
,所以我只能执行CallStatic()
publicstaticvoidshowinmobi(最终上下文)
{
//com.google.ads.mediation.inmobi.InMobiAdapter.disableHardwareAcceleration();
//((活动)上下文).runOnUiThread(新的Runnable(){
//公开募捐{
字符串CLASS_TO_LOAD=“com.inmobi.commons.inmobi”;
尝试
{
Class newClass=Class.forName(类到加载);
System.out.println(“类”+newClass+“已成功找到!”);
}
捕获(ClassNotFoundException ex)
{
例如printStackTrace();
System.out.println(“类”+类到加载+“未找到!”);
}
捕获(可任意丢弃)
{
System.out.println(“意外错误!”+any);
}
如果(i=null)
{
inmobi.commons.inmobi.initialize((活动)上下文,“我的单位id”);
interstitutionalinmobi=新的IMinterstitual((活动)上下文,“我的单位id”);
interstitualinmobi.loadinterstitual();
}
其他的
{
if(IMInterstitial.State()==IMInterstitial.State.READY){
(i)mobi.show();
interstitualinmobi.loadinterstitual();
}
}
//}
//});
这里是InMobi的Sohan
看起来您正试图在Unity中直接使用本机SDK。InMobi有一个Unity插件,您可以使用它。该插件充当本机SDK和应用程序之间的中介
您可以检查此项以了解进一步的集成详细信息
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();
}
}
//}
//});