观众网络插播/奖励广告秀Android在Unity上崩溃

观众网络插播/奖励广告秀Android在Unity上崩溃,android,unity3d,facebook-audience-network,Android,Unity3d,Facebook Audience Network,我试图在Android上显示Facebook广告。我已经在我的Android Studio项目中加入了观众网络.jar。还将活动添加到Android清单中。 这是build.gradle: 安卓{ 编译DK25版 BuildToolsVersion25.0.2 测试选项{ unitTests.returnDefaultValues=true } 默认配置{ 第15版 targetSdkVersion 25 版本代码1 版本名称1.0 TestInstrumentRunner android.s

我试图在Android上显示Facebook广告。我已经在我的Android Studio项目中加入了观众网络.jar。还将活动添加到Android清单中。 这是build.gradle:

安卓{ 编译DK25版 BuildToolsVersion25.0.2 测试选项{ unitTests.returnDefaultValues=true } 默认配置{ 第15版 targetSdkVersion 25 版本代码1 版本名称1.0 TestInstrumentRunner android.support.test.runner.AndroidJUnitRunner } 建筑类型{ 释放{ minifyEnabled false 收缩资源是错误的 proguard文件GetDefaultProGuard文件'proguard-android.txt','proguard rules.pro' 可调试错误 } 调试{ 可调试真 jniDebuggable true minifyEnabled false 收缩资源是错误的 } } } 依赖关系{ //必需-JUnit4框架 testCompile'junit:junit:4.12' //可选-Mockito框架 testCompile'org.mockito:mockito核心:1.10.19' 编译'com.google.android.gms:play services:10.2.0' 编译文件'libs/AudenceNetwork-4.24.0.jar' 编译'com.android.support:appcompat-v7:25.0.0' 编译'com.android.support:recyclerview-v7:25.0.0'
} 当Android Studio中有一个官方的Unity Facebook插件时,你不应该把Java和Facebook jar弄得一团糟。有关如何设置和获取实际SDK的说明,请参见本文

下载该插件时,您将发现InterstitularAscene、RewardedVideoAscene和NativeAscene场景包含示例代码,您应该加载InterstituralAscene场景,因为这正是您要查找的

下面是AudienceNetwork\Samples\Interstitual文件夹中InterstitutionAladTest.cs文件中的C Interstitual Ad示例


我终于解决了这个问题。
我从我的联合活动中销毁了关于暂停活动的观众网络广告。每次显示广告时,都会调用onPause事件,因此会造成混乱。

我不能使用Facebook插件,因为我正在为Android开发一个自定义广告中介。你的问题是,你想用Unity在Android上显示Facebook广告……为什么你不能使用已经为你编写的Facebook插件?
public class InterstitialAdTest : MonoBehaviour
{

    private InterstitialAd interstitialAd;
    private bool isLoaded;

    // UI elements in scene
    public Text statusLabel;

    // Load button
    public void LoadInterstitial ()
    {
        this.statusLabel.text = "Loading interstitial ad...";

        // Create the interstitial unit with a placement ID (generate your own on the Facebook app settings).
        // Use different ID for each ad placement in your app.
        InterstitialAd interstitialAd = new InterstitialAd ("YOUR_PLACEMENT_ID");
        this.interstitialAd = interstitialAd;
        this.interstitialAd.Register (this.gameObject);

        // Set delegates to get notified on changes or when the user interacts with the ad.
        this.interstitialAd.InterstitialAdDidLoad = (delegate() {
            Debug.Log ("Interstitial ad loaded.");
            this.isLoaded = true;
            this.statusLabel.text = "Ad loaded. Click show to present!";
        });
        interstitialAd.InterstitialAdDidFailWithError = (delegate(string error) {
            Debug.Log ("Interstitial ad failed to load with error: " + error);
            this.statusLabel.text = "Interstitial ad failed to load. Check console for details.";
        });
        interstitialAd.InterstitialAdWillLogImpression = (delegate() {
            Debug.Log ("Interstitial ad logged impression.");
        });
        interstitialAd.InterstitialAdDidClick = (delegate() {
            Debug.Log ("Interstitial ad clicked.");
        });

        // Initiate the request to load the ad.
        this.interstitialAd.LoadAd ();
    }

    // Show button
    public void ShowInterstitial ()
    {
        if (this.isLoaded) {
            this.interstitialAd.Show ();
            this.isLoaded = false;
            this.statusLabel.text = "";
        } else {
            this.statusLabel.text = "Ad not loaded. Click load to request an ad.";
        }
    }

    void OnDestroy ()
    {
        // Dispose of interstitial ad when the scene is destroyed
        if (this.interstitialAd != null) {
            this.interstitialAd.Dispose ();
        }
        Debug.Log ("InterstitialAdTest was destroyed!");
    }

    // Next button
    public void NextScene ()
    {
        SceneManager.LoadScene ("AdViewScene");
    }
}