Android Question AdMob in B4A 6 without Firebase

echapeta

Member
Licensed User
Longtime User
Hello,

What's the proper way to use AdMobs in B4A 6 without Firebase ?

Thank You!!
 

echapeta

Member
Licensed User
Longtime User
Hello gerredtor,

When I try , I get the following error compiling:

B4A version: 6.00
Parsing code. (0.11s)
Compiling code. (0.61s)
Compiling layouts code. (0.05s)
Organizing libraries. (2.27s)
Generating R file. Error
ERROR: resource directory 'c:\androidsdk\extras\google\google_play_services\libproject\google-play-services_lib\res' does not exist

It seems that using:

#AdditionalRes: C:\AndroidSDK\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms


There is no libproject folder in C:\AndroidSDK\extras\google\google_play_services\ .....

Do I have something missing ?
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
Dear Erel,

I think I had follow properly the instructions, but I get the following error while compiling:

B4A version: 6.00
Parsing code. (0.12s)
Compiling code. Error
Error parsing google-services.json:
Could not find file 'C:\Users\Eduardo Chapeta\Documents\Basic4AndroidProjects\Wardian\google-services.json'.

Can you help me ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can you help me ?
you need to place the google-services.json in your projectdir.
You get the json when you configure your app in firebase. See Firebase-Setup-Tutorial
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
DonManfred,

Done, but now I get the following error when compiling:

B4A version: 6.00
Parsing code. (0.12s)
Compiling code. (0.55s)
Compiling layouts code. (0.02s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:112: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.IAPTheme').

Can you help me ?
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
I think the problem is in android:theme="@android:style/Theme.Translucent" />

'************ Firebase Ads ************AddApplicationText(
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
android:theme="@style/Theme.IAPTheme"/>
)'************ Firebase Ads (end) ************
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
I just found a post talkling about "adding the library" and after adding
#AdditionalJar: com.google.android.gms:play-services-ads

The error is gone.

Thank You
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
Hello,

Now I can go up to installing and when starts in the debugger I get the following error:

Shutting down VM
FATAL EXCEPTION: main
Process: com.Wardian, PID: 3482
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.Wardian-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4967)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4559)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499)
at android.app.ActivityThread.access$1500(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1339)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.Wardian-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.ActivityThread.installProvider(ActivityThread.java:4952)
... 11 more
Suppressed: java.lang.ClassNotFoundException: com.google.firebase.provider.FirebaseInitProvider
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Force finishing activity com.Wardian/.main


Can you help me ?
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
Hello Erel,

So far I was using:

#AdditionalJar: com.google.android.gms:play-services-location
#AdditionalJar: com.google.android.gms:play-services-maps
#AdditionalJar: com.google.android.gms:play-services-ads


I will try !

Thank You.
 
Upvote 0

echapeta

Member
Licensed User
Longtime User
Hello Erel,

Now I have the following error:

B4A version: 6.00
Parsing code. (0.11s)
Compiling code. (0.43s)
Compiling layouts code. (0.04s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:114: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.IAPTheme').

The Manifest is:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'SetApplicationAttribute(android:theme, "@android:style/Theme.Material")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.


'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

'End of default text.


' B4A 6, google play services 30
'************ Google Play Services Base ************
AddApplicationText(
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="false"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@Integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************



' you must add one of these two permissions
' the permission you add will define the accuracy of location updates
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.INSTALL_PACKAGES)
AddPermission(android.permission.DELETE_PACKAGES)

' referrer
AddPermission(com.android.vending.INSTALL_REFERRER)
AddReceiverText(Starter,
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>)

' geo api key
AddApplicationText(
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyACNRWDKx4f1ykBMZ26fzlCojpW1X9Ujck"/>
)

AddPermission(android.permission.ACCESS_NETWORK_STATE)


' firebase
'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />)
AddApplicationText(
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD"/>
</intent-filter>
</receiver>

<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<provider
android:authorities="${applicationId}.firebaseinitprovider"
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:exported="false"
android:initOrder="100" />
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.measurement.UPLOAD"/>
</intent-filter>
</receiver>

<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
android:exported="false" />


<service
android:name="com.google.firebase.iid.FirebaseInstanceIdService"
android:exported="true">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
)
'************ Firebase Base (end) ************


'************ Firebase Ads ************
AddApplicationText(
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
android:theme="@style/Theme.IAPTheme"/>
)
'************ Firebase Ads (end) ************

Can you help me ?
 
Upvote 0
Top