java本机广告不会在android studio上显示

fwzugrvs  于 2021-07-07  发布在  Java
关注(0)|答案(0)|浏览(567)

我的本土广告似乎不能像这样装点和保持白色:

在我的xml中有两个本机广告:

<com.google.android.ads.nativetemplates.TemplateView
                android:id="@+id/my_template"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dp"
                app:gnt_template_type="@layout/gnt_small_template_view" />

<com.google.android.ads.nativetemplates.TemplateView
                    android:id="@+id/my_template2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="5dp"
                    app:gnt_template_type="@layout/gnt_small_template_view" />

在java类中,初始化mobile.ads后:

AdLoader.Builder builder = new AdLoader.Builder(this, getString(R.string.nativead_ad_unit_id));
        builder.forUnifiedNativeAd(new UnifiedNativeAd.OnUnifiedNativeAdLoadedListener() {
            @Override
            public void onUnifiedNativeAdLoaded(UnifiedNativeAd unifiedNativeAd) {
                TemplateView template = findViewById(R.id.my_template);
                template.setNativeAd(unifiedNativeAd);

                TemplateView template2 = findViewById(R.id.my_template2);
                template2.setNativeAd(unifiedNativeAd);

            }
        });

        AdLoader adLoader = builder.build();
        AdRequest adRequest = new AdRequest.Builder().build();
        adLoader.loadAd(adRequest);

我的项目中也有本地模板

在我的依赖中

implementation project(':nativetemplates')

日志

I/System.out: [okhttp]:check permission begin!
W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out: [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out: [okhttp]:check permission begin!
W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out: [OkHttp] sendRequest>>
    [OkHttp] sendRequest<<
I/System.out: [okhttp] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out: [socket]:check permission begin!
W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out: [socket] e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaUtils
I/System.out: [OkHttp] sendRequest>>
    [OkHttp] sendRequest<<
V/FA: Inactivity, disconnecting from the service
W/ConnectionTracker: Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjk@76f792
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1759)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1787)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:751)
        at com.google.android.gms.common.stats.ConnectionTracker.zza(com.google.android.gms:play-services-basement@@17.3.0:55)
        at com.google.android.gms.common.stats.ConnectionTracker.unbindService(com.google.android.gms:play-services-basement@@17.3.0:50)
        at com.google.android.gms.measurement.internal.zzis.zzah(com.google.android.gms:play-services-measurement-impl@@17.2.2:242)
        at com.google.android.gms.measurement.internal.zzis.zzak(com.google.android.gms:play-services-measurement-impl@@17.2.2:259)
        at com.google.android.gms.measurement.internal.zzis.zzc(com.google.android.gms:play-services-measurement-impl@@17.2.2:321)
        at com.google.android.gms.measurement.internal.zzir.zza(com.google.android.gms:play-services-measurement-impl@@17.2.2:2)
        at com.google.android.gms.measurement.internal.zzai.run(com.google.android.gms:play-services-measurement-impl@@17.2.2:7)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.google.android.gms.measurement.internal.zzgg.run(com.google.android.gms:play-services-measurement-impl@@17.2.2:21)

我所有的其他广告都在工作(视频奖励,横幅和Intertiel)。知道我错过了什么或做错了什么吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题