Implementing Google Admob Mobile Ads SDK (Android) in Sketchware without using Sketchware Admob Libraries
- Make sure your app supports the following API
- A minSdkVersion of 19 or higher
- A
compileSdkVersionof28or higher - Works on Sketchware Pro 3.0 fix 1 or higher
Add your AdMob app ID (identified in the
AdMob
UI) to your app's
AndroidManifest.xmllll file. To do so, add a <meta-data> tag with
android:name="com.google.android.gms.ads.APPLICATION_ID". You can find
your app ID in the AdMob UI. For
android:value, insert your own AdMob app ID,
surrounded by quotation marks.
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="3940256099942544~3347511713"/>
<!--To show real ads make sure you use your own Admob App id -->
<!--I am using these methods because Sketchware is not so powerful when it comes to AndroidManifest Merging -->
In a real app, use your actual AdMob app ID, not the one listed above. If you're just looking to experiment with the SDK in a Hello World app, you can use the sample app ID shown above.
Note also that failure to add the <meta-data> tag as shown above results
in a crash with the message:
The Google Mobile Ads SDK was initialized incorrectly.
(Optional) Declare AD_ID permission for
previous versions to work with Android 13.
If your app uses the Google Mobile Ads SDK version 20.4.0 or
higher, you can skip this step since the SDK automatically declares the
com.google.android.gms.permission.AD_ID permission and is able
to access the Advertising ID whenever it's available.
For apps that use the Google Mobile Ads SDK version 20.3.0 or
lower and are targeting Android 13, you must add
the com.google.android.gms.permission.AD_ID permission in the
AndroidManifest.xml file for the Google Mobile Ads SDK to
access the Advertising ID:
To learn more about the com.google.android.gms.permission.AD_ID
permission declaration, including how to disable it, please refer to this Play
Console article.
Initialize the Google Mobile Ads SDK
Before loading ads, have your app initialize the Google Mobile Ads SDK by calling MobileAds.initialize() which initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). This needs to be done only once, ideally at app launch.
Ads may be preloaded by the Google Mobile Ads SDK or mediation partner SDKs upon calling MobileAds.initialize(). If you need to obtain consent from users in the European Economic Area (EEA), set any request-specific flags (such as tagForChildDirectedTreatment or tag_for_under_age_of_consent), or otherwise take action before loading ads, ensure you do so before initializing the Google Mobile Ads SDK.
Here's an example of how to call the initialize() method in an Activity:
import com.google.android.gms.ads.MobileAds;
import com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;
import androidx.annotation.NonNull;<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />The Google Mobile Ads SDK was initialized incorrectly.

Hi, I'm Hamza Please send me an application sketchware that you are working on on to add AdMob ads without using Sketchware Admob Libraries
ReplyDelete