# Quick Start with Google Admob
This walkthrough shows how to show Google Admob's Native Ads in story format with Storyly in your Android application.
You can also check out the demo on GitHub
Before you begin
This walkthrough contains sample instance information. However, if you want to work with your own content as well, please login into Storyly Dashboard (opens new window) and get your instance token.
The sample instance information for testing purposes;
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhY2NfaWQiOjc2MCwiYXBwX2lkIjo0MDUsImluc19pZCI6NDA0fQ.1AkqOy_lsiownTBNhVOUKc91uc9fDcAxfQZtpm3nj40
Also, you need to update required settings from Storyly Dashboard Ad Settings (opens new window) to enable Ads in the instance.
Before you begin
Please check Google AdMob Mobile Ads SDK(Android) Quick Start Guide (opens new window) for correct integration.
You need to create a Native Ad Unit Id (opens new window) or for testing purposes use Test Ads (opens new window)
# Installation
First, declare the dependency for the Storyly Monetization SDK in your app’s module Gradle file (usually app/build.gradle
).
android {
dependencies {
...
// You should add this line
implementation 'com.appsamurai.storyly:storyly-monetization:<latest-version>'
...
}
}
TIP
Please do not forget to replace <latest-version>
. The latest version is (opens new window)
WARNING
Storyly Monetization SDK targets Android API level 19 (Android 4.4, KitKat)
or higher.
WARNING
You need to add Java 1.8 compatibility configuration as well. In your app’s module Gradle file (usually app/build.gradle
), please add the following instructions:
android {
compileOptions {
// You should add these two lines
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
# Initialize StorylyAdProvider
You need to set a StorylyAdProvider
to your StorylyView
instance to enable monetization feature.
storylyView.storylyAdViewProvider = StorylyAdViewProvider(this, ADMOB_NATIVE_AD_ID)
storylyView.setStorylyAdViewProvider(new StorylyAdViewProvider(this, ADMOB_NATIVE_AD_ID));
Just hit the run. Now, you should be able to enjoy Storyly
with ads 🎉!
# Google AdMob Consent Management
Before you begin
You may check Forward consent to the Google Mobile Ads SDK (opens new window) documentation for details.
StorylyAdViewProviders
provides a parameter, named adMobAdExtras
, in its constructor to pass NetworkExtrasBundle via addNetworkExtrasBundle
to Google AdMob.