Android Question How to use FirebaseAds in my app

sentechnologies

Member
Licensed User
anyone help me how to integrate firebase admob in my application. i tried several options described in the internet but i can't. my application always getting crash even after i added firebaseadmob lib 1.60 in my app.

my application getting crashed after i added the following

1. in manifest i added
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)

AddApplicationText(
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-5493432897041164~5486962956"/>
)

AddReplacement($ADMOB_APP_ID$, ca-app-pub-5493432897041164~5486962956)

2. i added FirebaseAdMob lib 1.60 in my project and am not added any code for admob.

but, after compilation my application is getting crash when open.
 

DonManfred

Expert
Licensed User
Longtime User
but, after compilation my application is getting crash when open.
Without an Error? Impossible

Post the Error. Without it noone can help
 
Upvote 0

sentechnologies

Member
Licensed User
1. My App Manifest

'AdMob
AddReplacement($ADMOB_APP_ID$, ca-app-pub-5493432897041164~5486962956)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseAdMob.FirebaseAds)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
'CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
'CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)

AddApplicationText(
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-5493432897041164~5486962956"/>
)

2. Added Library FirebaseAdMob(Version 1.60)

3. Error on Application in Release Mode and Open


Logger connected to: HMD Global Nokia 6.1
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_settoolbar (java line: 1247)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at org.yeskay.app.nextgendigital.main._settoolbar(main.java:1247)
at org.yeskay.app.nextgendigital.main._activity_create(main.java:461)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at org.yeskay.app.nextgendigital.main.afterFirstLayout(main.java:104)
at org.yeskay.app.nextgendigital.main.access$000(main.java:17)
at org.yeskay.app.nextgendigital.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:874)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 15 more
Caused by: java.lang.NoSuchFieldError: No static field Toolbar_menu of type I in class Landroidx/appcompat/R$styleable; or its superclasses (declaration of 'androidx.appcompat.R$styleable' appears in base.apk)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:346)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:232)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:228)
at de.amberhome.objects.appcompat.internal.InternalToolbar.<init>(InternalToolbar.java:25)
at de.amberhome.objects.appcompat.ACToolbarLightWrapper.innerInitialize(ACToolbarLightWrapper.java:28)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:67)
at de.amberhome.objects.appcompat.ACToolBarWrapper.Initialize(ACToolBarWrapper.java:66)
at de.amberhome.objects.appcompat.ACToolBarWrapper._initialize(ACToolBarWrapper.java:147)
... 18 more
--------- beginning of crash
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_settoolbar (java line: 1247)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at org.yeskay.app.nextgendigital.main._settoolbar(main.java:1247)
at org.yeskay.app.nextgendigital.main._activity_create(main.java:461)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at org.yeskay.app.nextgendigital.main.afterFirstLayout(main.java:104)
at org.yeskay.app.nextgendigital.main.access$000(main.java:17)
at org.yeskay.app.nextgendigital.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:874)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 15 more
Caused by: java.lang.NoSuchFieldError: No static field Toolbar_menu of type I in class Landroidx/appcompat/R$styleable; or its superclasses (declaration of 'androidx.appcompat.R$styleable' appears in base.apk)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:346)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:232)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:228)
at de.amberhome.objects.appcompat.internal.InternalToolbar.<init>(InternalToolbar.java:25)
at de.amberhome.objects.appcompat.ACToolbarLightWrapper.innerInitialize(ACToolbarLightWrapper.java:28)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:67)
at de.amberhome.objects.appcompat.ACToolBarWrapper.Initialize(ACToolBarWrapper.java:66)
at de.amberhome.objects.appcompat.ACToolBarWrapper._initialize(ACToolBarWrapper.java:147)
... 18 more
 
Upvote 0

sentechnologies

Member
Licensed User
now only , i had noticed that after updating appcompat sdk from 1.0.2 to 1.1.0. i am facing this error. how can i revert it to 1.0.2
upload_2019-9-10_11-36-9.png
 
Upvote 0

sentechnologies

Member
Licensed User
i used the below code in my Activity_Create() and it was worked fine in Appcompat SDK 1.0.2

Dim bd As BitmapDrawable
bd = LoadBitmap(File.DirAssets,"logo.png")

ActionToolBar.SetAsActionBar
ActionToolBar.Title = Application.LabelName
ActionToolBar.SubTitle = Application.VersionName
ActionToolBar.NavigationIconDrawable = bd
ActionToolBar.Elevation = 4dip

ABHelper.Initialize
AC.SetElevation(ActionToolBar,8dip)

ABHelper.ShowUpIndicator = False
'ABHelper.UpIndicatorDrawable = General.BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png"))

ActionToolBar.InitMenuListener
 
Upvote 0

sentechnologies

Member
Licensed User
in your appcompat example, which you sent in earlier post. i just added firebaseAdMob Lib in project, with above said Manifest content added and places google-services.json in b4a folder. and i got the same error in this app too. so, i come to conclusion there is some conflict issues between these. So, to revert back to normal state, i removed firebaseAdMob Lib and google-services.json from this project.

Now, the error continues. i don't know what is happening.

Logger connected to: HMD Global Nokia 6.1

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 344)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at org.yeskay.app.nextgendigital.main._activity_create(main.java:344)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at org.yeskay.app.nextgendigital.main.afterFirstLayout(main.java:104)
at org.yeskay.app.nextgendigital.main.access$000(main.java:17)
at org.yeskay.app.nextgendigital.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:874)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 14 more
Caused by: java.lang.NoSuchFieldError: No static field Toolbar_menu of type I in class Landroidx/appcompat/R$styleable; or its superclasses (declaration of 'androidx.appcompat.R$styleable' appears in base.apk)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:346)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:232)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:228)
at de.amberhome.objects.appcompat.internal.InternalToolbar.<init>(InternalToolbar.java:25)
at de.amberhome.objects.appcompat.ACToolbarLightWrapper.innerInitialize(ACToolbarLightWrapper.java:28)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:67)
at de.amberhome.objects.appcompat.ACToolBarWrapper.Initialize(ACToolBarWrapper.java:66)
at de.amberhome.objects.appcompat.ACToolBarWrapper._initialize(ACToolBarWrapper.java:147)
... 17 more
 
Last edited:
Upvote 0

sentechnologies

Member
Licensed User
Thanks Erel, i finally identified the source of error. it is raised because of SDK Build Tool. i uninstalled all versions of SDK build tool except 27.0.3, 28.0.3, 29.0.2.

Now, it is compiled as expected and working fine.
 
Upvote 0
Top