Getting Received log message: <Google:HTML> Incorrect native ad response. Click actions were not properly specified.witht error code 0

huangapple go评论96阅读模式
英文:

Getting Received log message: <Google:HTML> Incorrect native ad response. Click actions were not properly specified.witht error code 0

问题

以下是您提供的内容的翻译部分:

我正试图实现原生广告。在模拟器上尝试测试单元和真实单元时,我得到了错误代码0和3。在检查日志时,我发现了以下语句。

Received log message: &lt;Google:HTML&gt; Incorrect native ad response. Click actions were not properly specified

Ad failed to load : 0

当我使用真实的广告单元时,会出现错误代码0。

我正试图将这个原生广告填充到一个FrameLayout中。
以下是我XML文件中的代码片段:

&lt;LinearLayout
                android:id=&quot;@+id/adLayout&quot;
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:layout_gravity=&quot;bottom|center_horizontal&quot;
                android:orientation=&quot;vertical&quot;&gt;

                &lt;FrameLayout
                    android:id=&quot;@+id/nativeAdArea&quot;
                    android:layout_width=&quot;match_parent&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:visibility=&quot;gone&quot; /&gt;
               &lt;/LinearLayout&gt;
   

以下是我的Java代码片段。

    FrameLayout nativeAdArea;
    nativeAdArea = findViewById(R.id.nativeAdArea);

    private void showNativeBanner() {
        AdLoader adLoader = new AdLoader.Builder(this, getResources().getString(R.string.admob_native_mainactivity))
                .forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
                    @Override
                    public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
                        Log.e(&quot;nativead&quot;, &quot;loaded&quot;);

                        // 展示广告。
                        nativeAdArea.setVisibility(View.VISIBLE);

                        UnifiedNativeAdView adView = (UnifiedNativeAdView) getLayoutInflater()
                                .inflate(R.layout.layout_homepage_nativead, null);
                        // 这个方法将文本、图片和原生广告等填充到广告视图中。
                        mUnifiedNativeAd = populateUnifiedNativeAdView(unifiedNativeAd, adView);
                        nativeAdArea.removeAllViews();
                        nativeAdArea.addView(adView);
                    }
                })
                .withAdListener(new AdListener() {
                    @Override
                    public void onAdLoaded() {
                        super.onAdLoaded();
                        mUnifiedNativeAd.setOnPaidEventListener(new OnPaidEventListener() {
                            @Override
                            public void onPaidEvent(AdValue adValue) {
                                Bundle params = new Bundle();
                                params.putString(&quot;valuemicros&quot;, String.valueOf(adValue.getValueMicros()));
                                params.putString(&quot;currency&quot;, adValue.getCurrencyCode());
                                params.putString(&quot;precision&quot;, String.valueOf(adValue.getPrecisionType()));
                                params.putString(&quot;adunitid&quot;, getResources().getString(R.string.admob_native_mainactivity));
                                params.putString(&quot;network&quot;, Objects.requireNonNull(mUnifiedNativeAd.getResponseInfo()).getMediationAdapterClassName());
                                AnalyticsManager.logEvent(&quot;paid_ad_impression&quot;, params);
                            }
                        });
                    }

                    @Override
                    public void onAdFailedToLoad(int errorCode) {
                        Log.e(&quot;nativead&quot;, &quot;failedtoload&quot; + errorCode);
                        // 通过日志、更改UI等方式处理失败。
                        nativeAdArea.setVisibility(View.GONE);
//                        getSmaatoNativeAd();
                    }

                    @Override
                    public void onAdClicked() {
                        if (mFirebaseAnalytics == null) {
                            mFirebaseAnalytics = FirebaseAnalytics.getInstance(NewMainActivity.this);
                        }
                        Bundle adClickAnalyticsbundle = new Bundle();
                        adClickAnalyticsbundle.putString(&quot;app_version&quot;, BuildConfig.VERSION_NAME);
                        adClickAnalyticsbundle.putString(&quot;type&quot;, &quot;native&quot;);
                        adClickAnalyticsbundle.putString(&quot;ad_unit_name&quot;, &quot;homepage_lower_native&quot;);
                        mFirebaseAnalytics.logEvent(&quot;clicked_ad&quot;, adClickAnalyticsbundle);

                        Bundle abTestBundle = new Bundle();
                        abTestBundle.putString(&quot;app_version&quot;, BuildConfig.VERSION_NAME);
                        abTestBundle.putString(&quot;type&quot;, &quot;native&quot;);
                        mFirebaseAnalytics.logEvent(&quot;native_vs_adaptive&quot;, abTestBundle);
                    }

                })
                .withNativeAdOptions(new NativeAdOptions.Builder()
                        // 可以在NativeAdOptions.Builder类中使用的方法在此处用于指定单个选项设置。
                        .build())
                .build();

        AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class, extras)
                .build();
        runOnUiThread(() -&gt; {
            adLoader.loadAd(adRequest);
        });
    }

Getting Received log message: <Google:HTML> Incorrect native ad response. Click actions were not properly specified.witht error code 0

英文:

I am trying to implement native ads. I am getting error code 0 and 3 on both test units and real units when trying on emulator. While checking the logs I found the following statement.

Received log message: &lt;Google:HTML&gt; Incorrect native ad response. Click actions were not properly specified

Ad failed to load : 0

Error code 0 is coming when I am using real Ad units.

I am trying to populate this native ad inside a FrameLayout.
Below is a code snippet from my xml file:

&lt;LinearLayout
                android:id=&quot;@+id/adLayout&quot;
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:layout_gravity=&quot;bottom|center_horizontal&quot;
                android:orientation=&quot;vertical&quot;&gt;

                &lt;FrameLayout
                    android:id=&quot;@+id/nativeAdArea&quot;
                    android:layout_width=&quot;match_parent&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:visibility=&quot;gone&quot; /&gt;
               &lt;/LinearLayout&gt;
   

Here's my java code snippet.

    FrameLayout nativeAdArea;
    nativeAdArea = findViewById(R.id.nativeAdArea);

    private void showNativeBanner() {
        AdLoader adLoader = new AdLoader.Builder(this, getResources().getString(R.string.admob_native_mainactivity))
                .forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
                    @Override
                    public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
                        Log.e(&quot;nativead&quot;, &quot;loaded&quot;);

                        // Show the ad.
                        nativeAdArea.setVisibility(View.VISIBLE);

                        UnifiedNativeAdView adView = (UnifiedNativeAdView) getLayoutInflater()
                                .inflate(R.layout.layout_homepage_nativead, null);
                        // This method sets the text, images and the native ad, etc into the ad
                        // view.
                        mUnifiedNativeAd = populateUnifiedNativeAdView(unifiedNativeAd, adView);
                        nativeAdArea.removeAllViews();
                        nativeAdArea.addView(adView);
                    }
                })
                .withAdListener(new AdListener() {
                    @Override
                    public void onAdLoaded() {
                        super.onAdLoaded();
                        mUnifiedNativeAd.setOnPaidEventListener(new OnPaidEventListener() {
                            @Override
                            public void onPaidEvent(AdValue adValue) {
                                Bundle params = new Bundle();
                                params.putString(&quot;valuemicros&quot;, String.valueOf(adValue.getValueMicros()));
                                params.putString(&quot;currency&quot;, adValue.getCurrencyCode());
                                params.putString(&quot;precision&quot;, String.valueOf(adValue.getPrecisionType()));
                                params.putString(&quot;adunitid&quot;, getResources().getString(R.string.admob_native_mainactivity));
                                params.putString(&quot;network&quot;, Objects.requireNonNull(mUnifiedNativeAd.getResponseInfo()).getMediationAdapterClassName());
                                AnalyticsManager.logEvent(&quot;paid_ad_impression&quot;, params);
                            }
                        });
                    }

                    @Override
                    public void onAdFailedToLoad(int errorCode) {
                        Log.e(&quot;nativead&quot;, &quot;failedtoload&quot; + errorCode);
                        // Handle the failure by logging, altering the UI, and so on.
                        nativeAdArea.setVisibility(View.GONE);
//                        getSmaatoNativeAd();
                    }

                    @Override
                    public void onAdClicked() {
                        if (mFirebaseAnalytics == null) {
                            mFirebaseAnalytics = FirebaseAnalytics.getInstance(NewMainActivity.this);
                        }
                        Bundle adClickAnalyticsbundle = new Bundle();
                        adClickAnalyticsbundle.putString(&quot;app_version&quot;, BuildConfig.VERSION_NAME);
                        adClickAnalyticsbundle.putString(&quot;type&quot;, &quot;native&quot;);
                        adClickAnalyticsbundle.putString(&quot;ad_unit_name&quot;, &quot;homepage_lower_native&quot;);
                        mFirebaseAnalytics.logEvent(&quot;clicked_ad&quot;, adClickAnalyticsbundle);

                        Bundle abTestBundle = new Bundle();
                        abTestBundle.putString(&quot;app_version&quot;, BuildConfig.VERSION_NAME);
                        abTestBundle.putString(&quot;type&quot;, &quot;native&quot;);
                        mFirebaseAnalytics.logEvent(&quot;native_vs_adaptive&quot;, abTestBundle);
                    }

                })
                .withNativeAdOptions(new NativeAdOptions.Builder()
                        // Methods in the NativeAdOptions.Builder class can be
                        // used here to specify individual options settings.
                        .build())
                .build();

        AdRequest adRequest = new AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter.class, extras)
                .build();
        runOnUiThread(() -&gt; {
            adLoader.loadAd(adRequest);
        });
    }

    ```

[![Here&#39;s a snapshot of the log][1]][1]


  [1]: https://i.stack.imgur.com/f43d9.png

</details>


# 答案1
**得分**: 2

我在模拟器上也遇到了同样的问题,但是当我在真机上尝试相同的代码时,原生广告似乎可以正常工作。

<details>
<summary>英文:</summary>

I also faced same issue on emulator but when I tried same code on real device native ads seems to work perfectly. 

</details>



# 答案2
**得分**: 2

我遇到了相同的问题,并在这里找到了另一个正确的答案:https://stackoverflow.com/questions/67355780/flutter-native-admob-ad-failed-to-load-0

您需要在安装了Google Play框架的模拟器上测试您的应用程序。

<details>
<summary>英文:</summary>

I had the same issue and found another correct answer on this: https://stackoverflow.com/questions/67355780/flutter-native-admob-ad-failed-to-load-0

You need to test your app with an emulator that has Google Play framework installed.

</details>



huangapple
  • 本文由 发表于 2020年10月12日 20:34:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/64318020.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定