android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié),android用adb命令打開開發(fā)者模式-ESG跨境

android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié),android用adb命令打開開發(fā)者模式

來源網(wǎng)絡(luò)
來源網(wǎng)絡(luò)
2022-05-31
點(diǎn)贊icon 0
查看icon 755

android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié),android用adb命令打開開發(fā)者模式android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié)各位知道其他路子的求分享啊,我實(shí)在想不到什么方法了,可惜谷歌被屏蔽了,但是總比不能賺1毛錢好。我相信我的粉絲都是極客。注冊(cè)admobhttps://app......

android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié),android用adb命令打開開發(fā)者模式




android個(gè)人開發(fā)者接廣告admob以及需要注意的錯(cuò)誤細(xì)節(jié)

各位知道其他路子的求分享啊,我實(shí)在想不到什么方法了,可惜谷歌被屏蔽了,但是總比不能賺1毛錢好。我相信我的粉絲都是極客。

注冊(cè)admob

https://apps.admob.com

快速開始教程

https://developers.google.com/admob/android/quickstart hl=zhCN

創(chuàng)建應(yīng)用

創(chuàng)建banner

得到Y(jié)OUR_ADMOB_APP_ID

https://developers.google.com/admob/android/quickstart?hl=zhCN#import_the_mobile_ads_sdk

添加xml代碼

   android:id=@+id/ad_view

    android:layout_width=match_parent

    android:layout_height=wrap_content

    android:layout_centerHorizontal=true

    android:layout_alignParentBottom=true

    ads:adSize=BANNER

    ads:adUnitId=caapppub6391307239504132/6102840431 /

添加java代碼

package ...

import ...

import com.google.android.gms.ads.MobileAds;

public class MainActivity extends AppCompatActivity {

  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

//全局appid

MobileAds.initialize(this, caapppub6391307239504132~6124388718);

//    MobileAds.initialize(this, caapppub3940256099942544~3347511713);

    adView = findViewById(R.id.ad_view);

    // 建立發(fā)快遞廣告請(qǐng)求

    AdRequest adRequest = new AdRequest.Builder()

        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)

        .build();

    // 添加廣告監(jiān)聽.

    adView.setAdListener(new AdListener(){

      @Override

      public void onAdFailedToLoad(int i) {

        Log.w(TAG,load fail :+i);

      }

    });

//加載請(qǐng)求

    adView.loadAd(adRequest);  }

}

}

橫幅實(shí)現(xiàn)的官方教程在這里

https://developers.google.com/admob/android/banner?hl=zhCN

或者用代碼添加banner的方法

adView adView = new AdView(this);

adView.setAdSize(AdSize.BANNER);

adView.setAdUnitId(caapppub6391307239504132/6102840431);

規(guī)范細(xì)節(jié)

不要忘記代理一下聲明周期。

  /** Called when returning to the activity */

  @Override

  public void onResume() {

    super.onResume();

    if (adView != null) {

      adView.resume();

    }

  }

  /** Called before the activity is destroyed */

  @Override

  public void onDestroy() {

    if (adView != null) {

      adView.destroy();

    }

    super.onDestroy();

  }

各位測(cè)試沒效果的可以先直接把我的代碼copy測(cè)試效果如何。

插屏廣告

InterstitialAd mInterstitialAd = new InterstitialAd(this);//插頁廣告

    mInterstitialAd.setAdUnitId(xxxxx);

激勵(lì)廣告

    RewardedVideoAd mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);

    mRewardedVideoAd.setRewardedVideoAdListener(this);

    mRewardedVideoAd.loadAd(caapppub6391307239504132/8306864775, new AdRequest.Builder().build());

    AdLoader adLoader = new AdLoader.Builder(this, caapppub3940256099942544/2247696110)

        .forAppInstallAd(new NativeAppInstallAd.OnAppInstallAdLoadedListener() {

          @Override

          public void onAppInstallAdLoaded(NativeAppInstallAd appInstallAd) {

            // Show the app install ad.

          }

        })

        .forContentAd(new NativeContentAd.OnContentAdLoadedListener() {

          @Override

          public void onContentAdLoaded(NativeContentAd contentAd) {

            // Show the content ad.

          }

        })

        .withAdListener(new AdListener() {

          @Override

          public void onAdFailedToLoad(int errorCode) {

            // Handle the failure by logging, altering the UI, and so on.

          }

        })

        .withNativeAdOptions(new NativeAdOptions.Builder()

            // Methods in the NativeAdOptions.Builder class can be

            // used here to specify individual options settings.

            .build())

        .build();

    adLoader.loadAd(new AdRequest.Builder().build());

原生廣告

說實(shí)話原生廣告的,老美的文檔根本不全,有點(diǎn)亂,根本不知道某個(gè)東西如何來的。比如

  private void displayAppInstallAd(ViewGroup parent,NativeAppInstallAd ad) {

    // Inflate a layout and add it to the parent ViewGroup.

    LayoutInflater inflater = (LayoutInflater) parent.getContext()

        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    NativeAppInstallAdView adView = (NativeAppInstallAdView) inflater

        .inflate(R.layout.my_ad_layout, parent);

    // Locate the view that will hold the headline, set its text, and call the

    // NativeAppInstallAdViews setHeadlineView method to register it.

    TextView headlineView = adView.findViewById(R.id.ad_headline);

    headlineView.setText(ad.getHeadline());

    adView.setHeadlineView(headlineView);

    // Repeat the above process for the other assets in the NativeAppInstallAd

    // If the app is using a MediaView to display video, it should be

    // instantiated and passed to setMediaView. This view is a little different

    // in that the asset is populated automatically, so theres one less step.

    MediaView mediaView = (MediaView) adView.findViewById(R.id.ad_media);

    adView.setMediaView(mediaView);

    // Call the NativeAppInstallAdViews setNativeAd method to register the

    // NativeAdObject.

    adView.setNativeAd(ad);

    // Place the AdView into the parent.

    parent.addView(adView);

  }

這里需要傳遞一個(gè)參數(shù),文檔并沒有說是怎么出來的,我感覺需要找找他們的demo.

https://developers.google.com/admob/android/nativeadvanced?hl=zhCN

https://apps.admob.com/v2/home

將 Firebase 添加到您的 Android 項(xiàng)目

https://firebase.google.com/docs/android/setup

buildscript {

  // ...

  dependencies {

    // ...

    classpath com.google.gms:googleservices:3.2.0 // googleservices plugin

  }

}

allprojects {

  // ...

  repositories {

    // ...

    maven {

      url https://maven.google.com // Googles Maven repository

    }

  }

}

完整步驟

1.請(qǐng)使用此應(yīng)用 ID 完成說明:

2.請(qǐng)集成 SDK。在使用此廣告單元 ID 集成代碼時(shí),您需要指定廣告類型和展示位置:

3.請(qǐng)開始從 Firebase 控制臺(tái)下載配置文件。在下一步的最后,您將需要用到此文件。如果您無法訪問 Firebase 控制臺(tái),請(qǐng)與 Firebase 項(xiàng)目負(fù)責(zé)人聯(lián)系,請(qǐng)其將您添加為項(xiàng)目成員。

4.在您的應(yīng)用中實(shí)施 Firebase SDK。

5.完成集成后,請(qǐng)重新發(fā)布您的應(yīng)用,我們會(huì)在應(yīng)用概覽信息中心顯示相關(guān)的分析數(shù)據(jù)。

6.請(qǐng)查看 AdMob 政策,確保您的實(shí)現(xiàn)方案符合相關(guān)規(guī)定。

排錯(cuò)

on failed for task :childgit:app:processDebugGoogleServices.

File googleservices.json is missing. The Google Services Plugin cannot function without it.

Searched Location:

F:\src\git_project\qq_qqrobot\childgit\app\src\nullnull\debug\googleservices.json

F:\src\git_project\qq_qqrobot\childgit\app\src\debug\nullnull\googleservices.json

F:\src\git_project\qq_qqrobot\childgit\app\src\null

All firebase libraries must be either above or below 14.0.0

fix

  //https://dl.google.com/dl/android/maven2/index.html

implementation com.google.android.gms:playservicesads:15.0.0

  // implementation com.google.android.gms:playservicesads:12.0.1

  //implementation com.google.firebase:firebasecore:11.8.0

    implementation com.google.firebase:firebasecore:15.0.0

進(jìn)入控制臺(tái)點(diǎn)擊firexx 然后點(diǎn)擊下載配置文件。放到這個(gè)目錄

https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest

最終

   classpath com.google.gms:googleservices:3.2.1 // googleservices plugin

錯(cuò)誤碼

我剛開始的時(shí)候是0

public final class AdRequest {

  public static final int ERROR_CODE_INTERNAL_ERROR = 0;

  public static final int ERROR_CODE_INVALID_REQUEST = 1;

  public static final int ERROR_CODE_NETWORK_ERROR = 2;

  public static final int ERROR_CODE_NO_FILL = 3;

https://github.com/googleads/googleadsmobileandroidexamples

遇到問題可以提交到谷歌官方的論壇哈

https://groups.google.com/forum/#!forum/googleadmobadssdk

我現(xiàn)在官方的demo正常顯示,強(qiáng)烈建議大家也下載demo玩,其實(shí)看文檔是很不全的。demo的演示比較全,我這里就只給大家做個(gè)導(dǎo)師了,哈哈,

我這里一直提示0,我以為是要等幾個(gè)小時(shí),過了幾天打開官方網(wǎng)站看了一下,有一個(gè)警告信息。

提供詳細(xì)付款信息

只有在您提供此信息后 AdMob 才能投放您的廣告

這是比較棘手的,需要信用卡,而且我上次搞谷歌支付用招商這種雙幣信用卡都不行,雖然可以用來買0.99美元的書,虧了我不少錢,后面還是不行,最后不得已去淘寶購買了禮品卡才搞定了,然后用來購買開發(fā)者賬號(hào)

不過這次很幸運(yùn),成功了,ok,錯(cuò)誤碼從內(nèi)部錯(cuò)誤0 變成沒有廣告的錯(cuò)誤碼3了。

pulic static final int ERROR_CODE_INTERNAL_ERROR = 0;

  public static final int ERROR_CODE_INVALID_REQUEST = 1;

  public static final int ERROR_CODE_NETWORK_ERROR = 2;

  public static final int ERROR_CODE_NO_FILL = 3;


文章推薦
Google  如何創(chuàng)建銷售廣告,谷歌推廣怎么添加廣告系列
AppGalleryConnect服務(wù)支持Android、iOS、Web等平臺(tái),appgallery功能介紹
GMC賬號(hào)被封后成功申訴案例解析,gmc解封方法
App Store注冊(cè)美區(qū)(其他地區(qū))ID最新教程!兩步超簡(jiǎn)單!,iphone8 plus其他內(nèi)存怎么清理


特別聲明:以上文章內(nèi)容僅代表作者本人觀點(diǎn),不代表ESG跨境電商觀點(diǎn)或立場(chǎng)。如有關(guān)于作品內(nèi)容、版權(quán)或其它問題請(qǐng)于作品發(fā)表后的30日內(nèi)與ESG跨境電商聯(lián)系。

搜索 放大鏡
韓國平臺(tái)交流群
加入
韓國平臺(tái)交流群
掃碼進(jìn)群
歐洲多平臺(tái)交流群
加入
歐洲多平臺(tái)交流群
掃碼進(jìn)群
美國賣家交流群
加入
美國賣家交流群
掃碼進(jìn)群
ESG跨境專屬福利分享群
加入
ESG跨境專屬福利分享群
掃碼進(jìn)群
拉美電商交流群
加入
拉美電商交流群
掃碼進(jìn)群
亞馬遜跨境增長交流群
加入
亞馬遜跨境增長交流群
掃碼進(jìn)群
亞馬遜跨境增長交流群
加入
亞馬遜跨境增長交流群
掃碼進(jìn)群
拉美電商交流群
加入
拉美電商交流群
掃碼進(jìn)群
ESG獨(dú)家招商-PHH GROUP賣家交流群
加入
ESG獨(dú)家招商-PHH GROUP賣家交流群
掃碼進(jìn)群
《TikTok官方運(yùn)營干貨合集》
《TikTok綜合運(yùn)營手冊(cè)》
《TikTok短視頻運(yùn)營手冊(cè)》
《TikTok直播運(yùn)營手冊(cè)》
《TikTok全球趨勢(shì)報(bào)告》
《韓國節(jié)日營銷指南》
《開店大全-全球合集》
《開店大全-主流平臺(tái)篇》
《開店大全-東南亞篇》
《CD平臺(tái)自注冊(cè)指南》
通過ESG入駐平臺(tái),您將解鎖
綠色通道,更高的入駐成功率
專業(yè)1v1客戶經(jīng)理服務(wù)
運(yùn)營實(shí)操指導(dǎo)
運(yùn)營提效資源福利
平臺(tái)官方專屬優(yōu)惠

立即登記,定期獲得更多資訊

訂閱
聯(lián)系顧問

平臺(tái)顧問

平臺(tái)顧問 平臺(tái)顧問

微信掃一掃
馬上聯(lián)系在線顧問

icon icon

小程序

微信小程序

ESG跨境小程序
手機(jī)入駐更便捷

icon icon

返回頂部

【免費(fèi)領(lǐng)取】全球跨境電商運(yùn)營干貨 關(guān)閉
進(jìn)行中
進(jìn)行中
【活動(dòng)報(bào)名】2024年歐洲多藍(lán)海平臺(tái)招商沙龍
官方親臨,拆解phh group/eMAG/worten三個(gè)平臺(tái)商機(jī)
立即報(bào)名
進(jìn)行中
進(jìn)行中
TikTok運(yùn)營必備干貨包
包含8個(gè)TikTok最新運(yùn)營指南(市場(chǎng)趨勢(shì)、運(yùn)營手冊(cè)、節(jié)日攻略等),官方出品,專業(yè)全面!
免費(fèi)領(lǐng)取
進(jìn)行中
進(jìn)行中
韓國電商節(jié)日營銷指南
10+韓國電商重要營銷節(jié)點(diǎn)詳細(xì)解讀;2024各節(jié)日熱度選品助力引爆訂單增長;8大節(jié)日營銷技巧輕松撬動(dòng)大促流量密碼。
免費(fèi)領(lǐng)取
進(jìn)行中
進(jìn)行中
全球平臺(tái)詳解——全球合集
涵括全球100+個(gè)電商平臺(tái)的核心信息,包括平臺(tái)精煉簡(jiǎn)介、競(jìng)爭(zhēng)優(yōu)勢(shì)、熱銷品類、入駐要求以及入駐須知等關(guān)鍵內(nèi)容。
立即領(lǐng)取
進(jìn)行中
進(jìn)行中
全球平臺(tái)詳解——主流平臺(tái)篇
火爆全球的跨境電商平臺(tái)合集,平臺(tái)優(yōu)勢(shì)、開店選品、入駐條件盡在掌握
立即領(lǐng)取
進(jìn)行中
進(jìn)行中
全球平臺(tái)詳解——拉美篇
涵蓋9大熱門拉美電商平臺(tái),成熟的市場(chǎng)是跨境賣家的熱門選擇!
立即領(lǐng)取
進(jìn)行中
進(jìn)行中
全球平臺(tái)詳解——日韓篇
涵蓋10+日韓電商平臺(tái),入駐條件一看就懂,優(yōu)勢(shì)熱銷品應(yīng)有盡有
立即領(lǐng)取
進(jìn)行中
進(jìn)行中
全球平臺(tái)詳解——?dú)W洲篇
涵蓋20+歐洲電商平臺(tái),詳細(xì)解讀優(yōu)勢(shì)、入駐條件、熱銷品等
立即領(lǐng)取