简体   繁体   English

firebase横幅广告在我的应用中不起作用

[英]firebase banner ads is not working in my app

hello i have create one app and I integrate firebase ads but ad is not display i create demo app that work fine but when I implement this app is not working please help me.... 你好,我已经创建了一个应用程序,并且集成了Firebase广告,但是广告没有显示,我创建的演示应用程序可以正常工作,但是当我实现此应用程序无法正常工作时,请帮助我。

my app gradle file 我的应用程式Gradle档案

apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.wallpaper.hd"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'

    }
    dexOptions {
        javaMaxHeapSize "4g"
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    testCompile 'junit:junit:4.12'

    compile files('libs/mint-5.0.0.jar')

    compile 'com.facebook.fresco:webpsupport:0.10.0'

    compile 'com.facebook.fresco:webpsupport:0.10.0'

    compile 'com.android.support:appcompat-v7:23.4.0'

    compile 'com.android.support:design:23.4.0'

    compile 'com.android.support:cardview-v7:23.4.0'

    compile 'com.android.support:recyclerview-v7:23.4.0'

    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'

    compile 'me.neavo:volley:2014.12.09'

    compile 'com.facebook.fresco:fresco:0.10.0'

    compile 'com.facebook.fresco:animated-base-support:0.10.0'

    compile 'com.facebook.fresco:animated-gif:0.10.0'

    compile 'com.facebook.fresco:animated-webp:0.10.0'

    compile 'com.github.bumptech.glide:glide:3.6.1'

    compile 'com.android.support:support-v4:23.4.0'

    compile 'jp.wasabeef:recyclerview-animators:2.2.3'

    compile 'com.github.nirhart:parallaxscroll:1.0'

    compile 'com.eftimoff:android-viewpager-transformers:1.0.1@aar'

    compile 'com.jpardogo.googleprogressbar:library:1.2.0'

    compile 'com.mani:ThinDownloadManager:1.2.5'

    compile 'com.theartofdev.edmodo:android-image-cropper:2.2.+'

    compile 'com.facebook.android:facebook-android-sdk:4.+'

    compile 'com.google.android.gms:play-services-auth:9.0.0'

    compile 'com.loopj.android:android-async-http:1.4.9'

    compile 'com.melnykov:floatingactionbutton:1.3.0'

    compile 'com.google.firebase:firebase-messaging:9.0.0'

    compile 'com.android.support:multidex:1.0.0'

    compile 'com.firebase:firebase-client-android:2.5.1+'

    compile 'com.google.firebase:firebase-ads:9.0.0'

    compile 'com.github.hotchemi:android-rate:1.0.1'
   /* compile 'com.google.android.gms:play-services-ads:9.0.0'*/

    compile 'de.hdodenhof:circleimageview:2.1.0'

}
apply plugin: 'com.google.gms.google-services'

also add json file 还添加json文件

also add metadata in mainfest 还可以在mainfest中添加元数据

<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

my Activity java file 我的Activity Java文件

public class DesclaimerActivity extends AppCompatActivity {

    AdView mAdView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_desclaimer);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        initAllControls();
    }
    private void initAllControls() {
        WebView webView;
       MobileAds.initialize(getApplicationContext(), "ca-app-pub-4983020786912744~6430335512");

        mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder()
                .build();

        //.addTestDevice("FD515D9CC8B38F22AA850B22CA5D2F06")//.addTestDevice("764C199831DAD735E767FA0189CDDFB8")

        mAdView.loadAd(adRequest);


       /* webView=(WebView)findViewById(R.id.webView);
        webView.getSettings().setJavaScriptEnabled(true);
        String customHtml = "<html><body><font color='#272727'>"+getString(R.string.desclaimer)+"</font></body></html>";
        webView.loadData(customHtml, "text/html", "UTF-8");*/


    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        onBackPressed();
        return true;
    }
    @Override
    public void onPause() {
        if (mAdView != null) {
            mAdView.pause();
        }
        super.onPause();
    }

    /** Called when returning to the activity */
    @Override
    public void onResume() {
        super.onResume();
        if (mAdView != null) {
            mAdView.resume();
        }
    }

    /** Called before the activity is destroyed */
    @Override
    public void onDestroy() {
        if (mAdView != null) {
            mAdView.destroy();
        }
        super.onDestroy();
    }
}

in activity xml file add 在活动xml文件中添加

 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>

in string file add banner id 在字符串文件中添加横幅ID

<string name="banner_ad_unit_id">ca-app-pub-4983020786912744/9383801917</string>

Did you add the adactivity's config and theme to your manifest: 您是否将清单的配置和主题添加到清单中:

<activity android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />

And the classpath to the project-level build.gradle: 以及项目级build.gradle的类路径:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在使用firebase_admob在我的flutter应用中实施广告,但广告在发布版本apk中不起作用 - I am using firebase_admob to implement ads in my flutter app, but ads are not working in release build apk 为什么我不能在我的应用程序上显示横幅广告? - Why can't I display banner ads on my app? 横幅广告不适用于 Android Studio。 放置横幅广告后应用程序崩溃 - Banner ads not working for Android studio. App crashing after placing banner ad 横幅广告和非页内广告单元不起作用 - banner and interstitial ads units is not working 我正在使用firebase_admob在我的flutter应用中实施abmob,但是广告在发行版构建apk中不起作用 - I am using firebase_admob to implement abmob in my flutter app, but ads are not working in release build apk Admob横幅广告在Android上无法正常运行 - Admob banner ads not working properly on Android AdMob Cordova未在Cordova应用中显示广告横幅 - AdMob Cordova not showing Ads banner in Cordova app Webview应用程序未显示admob横幅广告 - Webview App not showing admob banner ads Facebook横幅广告导致应用程序崩溃 - Facebook banner ads cause app crashed Admob横幅广告使我的recyclerview滞后 - Admob banner ads making my recyclerview lag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM