마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Admob 안드로이드 전면광고 도와주세요 ㅠㅠ

0 추천

전면광고 테스트로 만들었는데, test-unit-id 로 할시에는 테스트 광고가 나오는데,

이것을 실제 unit-id를 넣은 후에 배포하면, 안나오네요.

ad 가 로딩이 안됫다고 나와요ㅠㅠ

스크린샷하고 코드 보여드릴테니 제발 도와주세요 ㅠㅠ

 

아래 튜토리얼 보고 똑같이 만든 코드입니다. 

https://developers.google.com/admob/android/interstitial

 

그리고 아래는 저의 admob 캡쳐 화면입니다.

 

 

아래는 저의 코드입니다. 


1. mainactivity.java
package admobtest.com.theaterwin.theateradmobtest;

public class MainActivity extends AppCompatActivity {
    private static final long GAME_LENGTH_MILLISECONDS = 3000;

    private InterstitialAd interstitialAd;
    private CountDownTimer countDownTimer;
    private Button retryButton;
    private boolean gameIsInProgress;
    private long timerMilliseconds;

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

        // Initialize the Mobile Ads SDK.
        MobileAds.initialize(this, "ca-app-pub-4942856506050335~1501960845");

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

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

        // Create the "retry" button, which tries to show an interstitial between game plays.
        retryButton = findViewById(R.id.retry_button);
        retryButton.setVisibility(View.INVISIBLE);
        retryButton.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 (countDownTimer != null) {
            countDownTimer.cancel();
        }

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

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


        };
    }

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

        if (gameIsInProgress) {
            resumeGame(timerMilliseconds);
        }
    }

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

    private void showInterstitial() {
        // Show the ad if it's ready. Otherwise toast and restart the game.
        if (interstitialAd != null && interstitialAd.isLoaded()) {
            interstitialAd.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 (!interstitialAd.isLoading() && !interstitialAd.isLoaded()) {
            AdRequest adRequest = new AdRequest.Builder().build();
            interstitialAd.loadAd(adRequest);
        }

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

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

}

 

2. Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="admobtest.com.theaterwin.theateradmobtest">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-4942856506050335~1501960845"/>

      

    </application>

</manifest>


3. vales - strings.xml

<resources>
    <string name="app_name">TheaterAdmobTest</string>
    <string name="action_settings">Settings</string>
    <string name="impossible_game">Impossible Game</string>
    <string name="ad_unit_id">ca-app-pub-4942856506050335/8049265316</string>

</resources>

jjunest (120 포인트) 님이 2018년 12월 7일 질문

1개의 답변

0 추천

안녕하세요.

해당 문제는 코드상의 오류가 아닙니다.

정확한 증상은 다음과 같은것으로 알고 있습니다.

 

1. 안드로이드 스튜디오 빌드 시 광고 잘 나옴

2. apk 파일로 다이렉트 설치 시 광고 잘 나옴

3. 플레이 스토어 퍼블리시 된 앱 설치시 애드몹 배너광고 로딩되지 않음 

   : 로그캣 메시지 : I / Ads: Ad failed to load: 3.

 

스택오버플로 : https://stackoverflow.com/questions/tagged/admob

구글 애드몹 헬프포럼 : https://productforums.google.com/forum/#!msg/google-admob-help-forum/8oc3pebOrFw/EicKPpUVDgAJ

 

을 참고해 보시면 11월 말부터 동시다발적으로 발생하기 시작한 문제이며, 12월 8일 여전히 해결되지 않고 있습니다.

애드몹 그래프를 보시면 요청수는 높으나 광고 배너가 나오지 않아 일치율이 점점 떨어지다 0에 수렴하는 문제가 생기고, 애드몹측의 어떠한 공식적인 발표도 없었기 때문에, 현재로서 해결할 수 있는 방법은 없습니다.

 

결론은...  애드몹 서버측의 문제라..코드상에 문제는 전혀 없습니다...

 

커피콩 (3,640 포인트) 님이 2018년 12월 8일 답변
...