我正在尝试实施原生广告。在模拟器上尝试时,我在测试单元和实际单元上都收到错误代码 0 和 3。在检查日志时,我发现了以下语句。
Received log message: <Google:HTML> Incorrect native ad response. Click actions were not properly specified
Ad failed to load : 0
当我使用真实的广告单元时,出现错误代码 0。
我正在尝试在 FrameLayout 中填充此原生广告。下面是我的 xml 文件中的代码片段:
<LinearLayout
android:id="@+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:orientation="vertical">
<FrameLayout
android:id="@+id/nativeAdArea"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的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("nativead", "loaded");
// Show the ad.
nativeAdArea.setVisibility(View.VISIBLE);
UnifiedNativeAdView adView = (UnifiedNativeAdView) …Run Code Online (Sandbox Code Playgroud)