When I created a new AdMob app, I got an App ID and Ad unit ID for every ad unit. But I don't see where to assign App ID, for example, with AdMobBanner there is only adUnitID prop.
Thanks,
I know how to do it now :)
For other who find answer:
iOS: AppDelegate.m (excerpt) @import GoogleMobileAds; and add:
[GADMobileAds configureWithApplicationID:@"YOUR_ADMOB_APP_ID"];
Android: MainActivity.java add import com.google.android.gms.ads.MobileAds and
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
Can write how you did it ?
I tried what @Dictory said but I get errors in Android Studio.
Can you maybe provide a sample of how the full code in MainActivity.java ?
Thank you !
@Kris4an7
package ...
import ...
import android.os.Bundle;
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);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}
...
}
from quick start
@Tiendq @Dictory Out of curiosity, what is the point of assigning the AdMob App ID if ads seem to work fine with just the adUnitId? Do I miss out on anything? I didn't know about AdMob App ID.
@booboothefool Well, none from my experience.
I thought I need it, hence the question, but it turned out to work fine without it.
Thanks for the answer @Dictory !
@booboothefool it's for reporting, you could have several ad units in an app.
When I try @Dictory's method, my app "keeps stopping"
Most helpful comment
For other who find answer:
iOS:
AppDelegate.m(excerpt)@import GoogleMobileAds;and add:[GADMobileAds configureWithApplicationID:@"YOUR_ADMOB_APP_ID"];Android:
MainActivity.javaaddimport com.google.android.gms.ads.MobileAdsandMobileAds.initialize(this, "YOUR_ADMOB_APP_ID");