Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓2.3中的Admob_Android_Admob_Android 2.3 Gingerbread - Fatal编程技术网

Android 安卓2.3中的Admob

Android 安卓2.3中的Admob,android,admob,android-2.3-gingerbread,Android,Admob,Android 2.3 Gingerbread,我有一个Android应用程序,我正试图在其中显示广告。在运行安卓4.1.2的Galaxy Nexus上,这些广告显示得很好,但在运行安卓2.3的Droid2上,它们不会显示 我找遍了所有的地方,我不知道我做错了什么 Android清单: <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/> <uses-permission android:name="android.permis

我有一个Android应用程序,我正试图在其中显示广告。在运行安卓4.1.2的Galaxy Nexus上,这些广告显示得很好,但在运行安卓2.3的Droid2上,它们不会显示

我找遍了所有的地方,我不知道我做错了什么

Android清单:

<uses-sdk android:minSdkVersion="8"
        android:targetSdkVersion="16"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="@string/app_name" android:icon="@drawable/sms_logo_green_w_blue">
    <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

让您的类实现
AdListener
,这样您就可以在日志中获得关于请求发生了什么的更多信息

public class MyClass extends Activity implements AdListener {
  private static final String LOG_TAG = "MyClass";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Get the ad.
    AdView adView = (AdView) findViewById(R.id.adView);

    // Set the AdListener.
    adView.setAdListener(this);

    // Your other code here.
    ...
  }

  /** Called when an ad is clicked and about to return to the application. */
  @Override
  public void onDismissScreen(Ad ad) {
    Log.d(LOG_TAG, "onDismissScreen");
    Toast.makeText(this, "onDismissScreen", Toast.LENGTH_SHORT).show();
  }

  /** Called when an ad was not received. */
  @Override
  public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error) {
    String message = "onFailedToReceiveAd (" + error + ")";
    Log.d(LOG_TAG, message);
    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
  }

  /**
   * Called when an ad is clicked and going to start a new Activity that will
   * leave the application (e.g. breaking out to the Browser or Maps
   * application).
   */
  @Override
  public void onLeaveApplication(Ad ad) {
    Log.d(LOG_TAG, "onLeaveApplication");
    Toast.makeText(this, "onLeaveApplication", Toast.LENGTH_SHORT).show();
  }

  /**
   * Called when an Activity is created in front of the app (e.g. an
   * interstitial is shown, or an ad is clicked and launches a new Activity).
   */
  @Override
  public void onPresentScreen(Ad ad) {
    Log.d(LOG_TAG, "onPresentScreen");
    Toast.makeText(this, "onPresentScreen", Toast.LENGTH_SHORT).show();
  }

  /** Called when an ad is received. */
  @Override
  public void onReceiveAd(Ad ad) {
    Log.d(LOG_TAG, "onReceiveAd");
    Toast.makeText(this, "onReceiveAd", Toast.LENGTH_SHORT).show();
  }
}

我是个白痴。我在Droid2上安装了一个adblock应用程序,我已经忘记了(我已经有很长一段时间没有使用这个设备了)


对不起,浪费了你的时间!尽管如此,我还是对你的答案投了赞成票,因为它确实帮助我认识到了问题所在。

代码很好,但我们需要查看LogCat输出。有撞车吗?这是一个网络错误吗(你的2.3设备上没有互联网?AdRequest成功但缺乏库存(你没有在你的2.3设备上添加TestDevice,你的帐户还没有收到实时广告)?我已经查看了logcat。没有崩溃,logcat中没有错误,我在2.3设备上有互联网(已连接到wifi,并且正在接收电子邮件,因此已验证其工作正常,)该帐户已在4.1.2设备上收到实时广告。我在这里完全目瞪口呆。感谢您的尝试:-/您能粘贴日志吗?必须有相关内容。如果真的没有,可能甚至没有发出请求?看起来您正在使用中介ID?ID连接到什么网络?我想ect查看其他日志。我正在使用的另一个广告网络称为“点击换点击”。在过去一周左右的时间里,我一直在与他们的技术支持合作解决一些问题。他们认为这个问题可能是由于他们的SDK造成的,但他们仍在研究。在此之前,任何建议都将不胜感激(因为我不能100%确定这个问题是由他们造成的。)检查我的上一次编辑。没有从中得到任何输出。不知道发生了什么。你是否通过
adView.setAdListener(this);
设置了adlistener?好吧,这花了很长时间才得到任何结果,但是“onFailedToReceiveAd”给了我“发生了网络错误”添加了更多logcat信息。我今晚要睡觉了,明天再回来。感谢您抽出时间来帮助我。
com.google.ads.AdView adView = new com.google.ads.AdView(this, AdSize.BANNER, this.getResources().getString(R.string.mediation_id));
    LinearLayout layout = (LinearLayout)findViewById(R.id.mainAdLayout);

// Add the adView to it
layout.addView(adView);

AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("<my device id>");
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

adView.loadAd(adRequest);
I/Ads     ( 3220): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":0,"session_id":"16659815784493691135","u_sd":1.5,"seq_num":"1","slotname":"5ae6fdb32cdf4c1a","u_w":320,"msid":"com.havens1515.autorespondfree","js":"afma-sdk-a-v6.2.1","mv":"8011016.com.android.vending","isu":"B78F2F5C240A24F31F6EF9D6EBD74706","cipa":1,"bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"17.android.com.havens1515.autorespondfree","hl":"en","ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"gnt":6,"u_h":569,"carrier":"31000","bas_on":0,"ptime":0,"u_audio":1});</script></head><body></body></html>

W/asset   ( 3220): deep redirect failure from 0x0103003e => 0x02060007, defStyleAttr=0x0101006c, defStyleRes=0x01030019, style=0x00000000

D/dalvikvm( 3220): GC_CONCURRENT freed 225K, 49% free 2928K/5639K, external 513K/519K, paused 2ms+7ms

D/dalvikvm( 3220): GC_EXTERNAL_ALLOC freed 2K, 49% free 2925K/5639K, external 513K/519K, paused 55ms

D/ViewConsistency( 3220): AbsListView android.widget.ListView@40516210 enabled= true

D/ViewConsistency( 3220): AbsListView android.widget.ListView@40516210 enabled= true
I/Ads     ( 3220): To get test ads on this device, call adRequest.addTestDevice("B78F2F5C240A24F31F6EF9D6EBD74706");

I/Ads     ( 3220): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":1,"session_id":"16659815784493691135","u_sd":1.5,"seq_num":"2","slotname":"5ae6fdb32cdf4c1a","u_w":320,"msid":"com.havens1515.autorespondfree","js":"afma-sdk-a-v6.2.1","mv":"8011016.com.android.vending","isu":"B78F2F5C240A24F31F6EF9D6EBD74706","cipa":1,"bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"17.android.com.havens1515.autorespondfree","hl":"en","ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"gnt":6,"u_h":569,"carrier":"31000","bas_on":0,"ptime":400,"u_audio":1});</script></head><body></body></html>
D/dalvikvm( 3505): Debugger has detached; object registry had 1 entries

W/ActivityThread( 3505): Application com.havens1515.autorespondfree can be debugged on port 8100...

D/szipinf ( 3505): Initializing inflate state

E/dalvikvm( 3505): Could not find class 'android.app.Notification$Builder', referenced from method com.havens1515.autorespondfree.AutoRespond.showNotification

W/dalvikvm( 3505): VFY: unable to resolve new-instance 15 (Landroid/app/Notification$Builder;) in Lcom/havens1515/autorespondfree/AutoRespond;

D/dalvikvm( 3505): VFY: replacing opcode 0x22 at 0x0031

D/dalvikvm( 3505): VFY: dead code 0x0033-00cd in Lcom/havens1515/autorespondfree/AutoRespond;.showNotification (Landroid/content/Context;)V

D/dalvikvm( 3505): GC_EXTERNAL_ALLOC freed 62K, 50% free 2706K/5379K, external 0K/0K, paused 40ms

I/Database( 3505): sqlite returned: error code = 0, msg = Recovered 14 frames from WAL file /data/data/com.havens1515.autorespondfree/databases/webview.db-wal

I/Database( 3505): sqlite returned: error code = 0, msg = Recovered 18 frames from WAL file /data/data/com.havens1515.autorespondfree/databases/webviewCache.db-wal

I/Ads     ( 3505): To get test ads on this device, call adRequest.addTestDevice("B78F2F5C240A24F31F6EF9D6EBD74706");

W/asset   ( 3505): deep redirect failure from 0x0103003e => 0x02060007, defStyleAttr=0x0101006c, defStyleRes=0x01030019, style=0x00000000

D/dalvikvm( 3505): GC_CONCURRENT freed 204K, 49% free 2926K/5639K, external 513K/519K, paused 2ms+4ms

D/dalvikvm( 3505): GC_EXTERNAL_ALLOC freed 24K, 49% free 2902K/5639K, external 513K/519K, paused 51ms

I/Ads     ( 3505): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":0,"session_id":"212234885725326360","u_sd":1.5,"seq_num":"1","slotname":"5ae6fdb32cdf4c1a","u_w":320,"msid":"com.havens1515.autorespondfree","js":"afma-sdk-a-v6.2.1","mv":"8011016.com.android.vending","isu":"B78F2F5C240A24F31F6EF9D6EBD74706","cipa":1,"bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"17.android.com.havens1515.autorespondfree","hl":"en","ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"gnt":6,"u_h":569,"carrier":"31000","bas_on":0,"ptime":0,"u_audio":1});</script></head><body></body></html>
D/ViewConsistency( 3505): AbsListView android.widget.ListView@40536910 enabled= true

D/ViewConsistency( 3505): AbsListView android.widget.ListView@40536910 enabled= true

I/Ads     ( 3505): To get test ads on this device, call adRequest.addTestDevice("B78F2F5C240A24F31F6EF9D6EBD74706");

I/Ads     ( 3505): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":1,"session_id":"212234885725326360","u_sd":1.5,"seq_num":"2","slotname":"5ae6fdb32cdf4c1a","u_w":320,"msid":"com.havens1515.autorespondfree","js":"afma-sdk-a-v6.2.1","mv":"8011016.com.android.vending","isu":"B78F2F5C240A24F31F6EF9D6EBD74706","cipa":1,"bas_off":0,"format":"320x50_mb","oar":0,"net":"wi","app_name":"17.android.com.havens1515.autorespondfree","hl":"en","ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"gnt":6,"u_h":569,"carrier":"31000","bas_on":0,"ptime":268,"u_audio":1});</script></head><body></body></html>

W/webcore ( 3505): Can't get the viewWidth after the first layout

W/webcore ( 3505): Can't get the viewWidth after the first layout
I/Ads     ( 5877): AdLoader timed out after 60000ms while getting the URL.

D/webviewglue( 5877): nativeDestroy view: 0x1e94e8

I/Ads     ( 5877): onFailedToReceiveAd(A network error occurred.)

D/AutoRespondFree( 5877): onFailedToReceiveAd (A network error occurred.)
public class MyClass extends Activity implements AdListener {
  private static final String LOG_TAG = "MyClass";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Get the ad.
    AdView adView = (AdView) findViewById(R.id.adView);

    // Set the AdListener.
    adView.setAdListener(this);

    // Your other code here.
    ...
  }

  /** Called when an ad is clicked and about to return to the application. */
  @Override
  public void onDismissScreen(Ad ad) {
    Log.d(LOG_TAG, "onDismissScreen");
    Toast.makeText(this, "onDismissScreen", Toast.LENGTH_SHORT).show();
  }

  /** Called when an ad was not received. */
  @Override
  public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error) {
    String message = "onFailedToReceiveAd (" + error + ")";
    Log.d(LOG_TAG, message);
    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
  }

  /**
   * Called when an ad is clicked and going to start a new Activity that will
   * leave the application (e.g. breaking out to the Browser or Maps
   * application).
   */
  @Override
  public void onLeaveApplication(Ad ad) {
    Log.d(LOG_TAG, "onLeaveApplication");
    Toast.makeText(this, "onLeaveApplication", Toast.LENGTH_SHORT).show();
  }

  /**
   * Called when an Activity is created in front of the app (e.g. an
   * interstitial is shown, or an ad is clicked and launches a new Activity).
   */
  @Override
  public void onPresentScreen(Ad ad) {
    Log.d(LOG_TAG, "onPresentScreen");
    Toast.makeText(this, "onPresentScreen", Toast.LENGTH_SHORT).show();
  }

  /** Called when an ad is received. */
  @Override
  public void onReceiveAd(Ad ad) {
    Log.d(LOG_TAG, "onReceiveAd");
    Toast.makeText(this, "onReceiveAd", Toast.LENGTH_SHORT).show();
  }
}