Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.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
Java Admob android ads错误_Java_Android_Admob - Fatal编程技术网

Java Admob android ads错误

Java Admob android ads错误,java,android,admob,Java,Android,Admob,我有下面的谷歌代码,我试着运行这个代码的广告,没有什么只是有错误和唐;不要展示广告 这是主课 公共类MyActivity扩展了ActionBarActivity{ private static final long GAME_LENGTH_MILLISECONDS = 3000; private PublisherInterstitialAd mInterstitialAd; private CountDownTimer mCountDownTimer; private Button mRet

我有下面的谷歌代码,我试着运行这个代码的广告,没有什么只是有错误和唐;不要展示广告

这是主课 公共类MyActivity扩展了ActionBarActivity{

private static final long GAME_LENGTH_MILLISECONDS = 3000;

private PublisherInterstitialAd mInterstitialAd;
private CountDownTimer mCountDownTimer;
private Button mRetryButton;
private boolean mGameIsInProgress;
private boolean mAdIsLoading;
private long mTimerMilliseconds;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    // Create the InterstitialAd and set the adUnitId.
    mInterstitialAd = new PublisherInterstitialAd(this);
    // Defined in res/values/strings.xml
    mInterstitialAd.setAdUnitId(getString(R.string.ad_unit_id));

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            startGame();
        }

        @Override
        public void onAdLoaded() {
            mAdIsLoading = false;
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            mAdIsLoading = false;
        }
    });

    // Create the "retry" button, which tries to show an interstitial between game plays.
    mRetryButton = ((Button) findViewById(R.id.retry_button));
    mRetryButton.setVisibility(View.INVISIBLE);
    mRetryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showInterstitial();
        }
    });

    startGame();
}

private void createTimer(final long milliseconds) {
    // Create the game timer, which counts down to the end of the level
    // and shows the "retry" button.
    if (mCountDownTimer != null) {
        mCountDownTimer.cancel();
    }

    final TextView textView = ((TextView) findViewById(R.id.timer));

    mCountDownTimer = new CountDownTimer(milliseconds, 50) {
        @Override
        public void onTick(long millisUnitFinished) {
            mTimerMilliseconds = millisUnitFinished;
            textView.setText("seconds remaining: " + ((millisUnitFinished / 1000) + 1));
        }

        @Override
        public void onFinish() {
            mGameIsInProgress = false;
            textView.setText("done!");
            mRetryButton.setVisibility(View.VISIBLE);
        }
    };
}

@Override
public void onResume() {
    // Start or resume the game.
    super.onResume();

    if (mGameIsInProgress) {
        resumeGame(mTimerMilliseconds);
    }
}

@Override
public void onPause() {
    // Cancel the timer if the game is paused.
    mCountDownTimer.cancel();
    super.onPause();
}

private void showInterstitial() {
    // Show the ad if it's ready. Otherwise toast and restart the game.
    if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
    } else {
        Toast.makeText(this, "Ad did not load", Toast.LENGTH_SHORT).show();
        startGame();
    }
}

private void startGame() {
    // Request a new ad if one isn't already loaded, hide the button, and kick off the timer.
    if (!mAdIsLoading && !mInterstitialAd.isLoaded()) {
        mAdIsLoading = true;
        PublisherAdRequest adRequest = new PublisherAdRequest.Builder().addTestDevice("98C0D5CB2DE5053D838806F85C1F9AE5").build();
        mInterstitialAd.loadAd(adRequest);
    }

    mRetryButton.setVisibility(View.INVISIBLE);
    resumeGame(GAME_LENGTH_MILLISECONDS);
}

private void resumeGame(long milliseconds) {
    // Create a new timer for the correct length and start it.
    mGameIsInProgress = true;
    mTimerMilliseconds = milliseconds;
    createTimer(milliseconds);
    mCountDownTimer.start();
}
}

这就是我尝试代码时的错误

19367/com.google.android.gms.example.interstitialexample I/Ads: Starting ad request.
12-31 14:23:32.885 19367-
12-31 14:23:32.915 19367-19367/com.google.android.gms.example.interstitialexample D/Atlas: Validating map...
12-31 14:23:33.075 19367-19367/com.google.android.gms.example.interstitialexample D/FindExtension: FindExtension: before mHardwareRenderer.initialize, mSurface.isValid() = true
12-31 14:23:43.225 19367-19384/com.google.android.gms.example.interstitialexample W/Ads: There was a problem getting an ad response. ErrorCode: 0
12-31 14:23:43.245 19367-19367/com.google.android.gms.example.interstitialexample W/Ads: Failed to load ad: 0

代码运行正常,但不显示间隙广告

只需等待一两天,它就会自动修复。我也看到过这种情况。代码没有问题


另外,我希望您能在设备上试用,而不仅仅是模拟器。如果还没有在实际的android设备上试用过,试试看。

看这里,我正在试用其他软件包名称,但什么都没有。男士:(我有其他应用程序,但看不到广告。谷歌从未向我发送过邮件@Tauqir