问题
I had created a banner admob ad using this link. App it was working good. I even got publisher id and I was able to view impressions and clicks from Admob website. But after I completed the development, I uploaded the app on play store and i am not able to view any ads impression/clicks from Admob website though ads are showing inside the app downloaded from playstore. Though Impressions/clicks are showing as long as I am viewing it on test device. But no impression/clicks are updating if I download and use it from google playstore. I have linked the app from playstore. Around 50 people have downloaded the app and it has been 3 days but no update in Impressions/clicks. Now what I need to do to be able to track impressions or clicks. Do I need to get a new publisher ID? If so what are the steps to obtain it. Thanks in advance. Help me I'm new in admob.
I am using this code in the activities where I want to show the ad
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
.
.
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Inside android manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
.
.
.
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
In the strings.xml file
<string name="banner_ad_unit_id">ca-app-pub-3**************3/*********7</string>
Inside the activities xml I have used the following code
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
Also, I'm using two different email-Ids the one for admob is different from that of play store id from which I have uploaded the app. Here's the link of the screenshot of the admob.
http://postimg.org/image/kh26x3oyh/
回答1:
Note: Ads can only be shown to the user, if they are available from the ad network.
Do you have both these permissions defined?
< uses-permission android:name="android.permission.INTERNET" />
< uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Make sure the banner add unit is not a test.
Add a listener to see if adds are being loaded:
mAdView = (AdView) findViewById(R.id.adView); mAdView.setAdListener(new AdListener() { // Called when an ad is loaded. @Override public void onAdLoaded() { Log.e(TAG, "Google onAdLoaded"); } // Called when an ad failed to load. @Override public void onAdFailedToLoad(int error) { String message = "Google onAdFailedToLoad: " + getErrorReason(error); Log.e(TAG, message); } // 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 onAdOpened() { Log.e(TAG, "Google onAdOpened"); } // Called when an ad is clicked and about to return to the application. @Override public void onAdClosed() { Log.e(TAG, "Google onAdClosed"); } // 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 onAdLeftApplication() { Log.d(TAG, "Google onAdLeftApplication"); } }); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest);
You also need this function:
private String getErrorReason(int errorCode) {
// Gets a string error reason from an error code.
String errorReason = "";
switch (errorCode) {
case AdRequest.ERROR_CODE_INTERNAL_ERROR:
errorReason = "Internal error";
break;
case AdRequest.ERROR_CODE_INVALID_REQUEST:
errorReason = "Invalid request";
break;
case AdRequest.ERROR_CODE_NETWORK_ERROR:
errorReason = "Network Error";
break;
case AdRequest.ERROR_CODE_NO_FILL:
errorReason = "No fill";
break;
}
return errorReason;
}
来源:https://stackoverflow.com/questions/31640814/admob-impressions-clicks-not-updating-after-uploading-it-on-playstore