Android Question admob Firebase problem

abhishek007p

Active Member
Licensed User
Longtime User
in the manifest editor comment this line and see if it compiles, if yes then json file is either missing or invalid.
'CreateResourceFromFile("google-services", "google-services.json")
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
yes, I have these components pasted.
after commenting on this line of code, I am getting this error

B4A Version: 7.80
Parsing the code. (0.23s)
Compiling the code. (0.36s)
Compiling the layout code. (0.17s)
Organizing libraries. (3.17s)
Generating the R. Error file
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:font
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontStyle
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontWeight
 
Upvote 0

abhishek007p

Active Member
Licensed User
Longtime User
i suggest your to make a sample project only for ads and then test out the ads to isolate and detect the problem.
you also need to install the following components from SDK manager - Android Support Repository, Google Play services, Google Repository.

Found answer to your problem. download the latest android image or at least the one you are targeting. https://www.b4x.com/android/forum/threads/runtimepermissions-library-issue.89210/
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
setting to : "C:\android-sdk\platforms\android-27\android.jar" it helped, now the program compiles.
When I uncomment the line : "CreateResourceFromFile("google-services", "google-services.json"
the problem remains

B4A Version: 7.80
Parsing the code. (0.25s)
Compiling the code. error
The object reference has not been set to the instance of the object.
Whether it can be a problem with the file google-services.json?
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
B4X:
'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.
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(modsmsodb,
<intent-filter>
    <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)

'************ 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) ************

'************ 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 Notifications ************
AddApplicationText(
    <service
  android:name="com.google.firebase.messaging.FirebaseMessagingService"
  android:exported="true">
  <intent-filter android:priority="-500">
  <action android:name="com.google.firebase.MESSAGING_EVENT" />
  </intent-filter>
  </service>
   <service android:name="anywheresoftware.b4a.objects.FirebaseNotificationsService">
     <intent-filter>
  <action android:name="com.google.firebase.MESSAGING_EVENT"/>
     </intent-filter>
   </service>
)
'************ Firebase Notifications (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) ************

'************ Firebase Auth ************
AddApplicationText(
  <activity android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:excludeFromRecents="true"
  android:exported="false" />

  <service
  android:name="com.google.android.gms.auth.api.signin.RevocationBoundService"
  android:exported="true"
  android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
)
'************ Firebase Auth (end) ************
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
I will listen to abhishek007p and create a new project with a new file.
Thank you for your answer.
 
Upvote 0

abhishek007p

Active Member
Licensed User
Longtime User
you dont need Firebase Notifications, Firebase Auth if you just want to show ads.

you need to get the json file from admob website (it is unique for each project). if you dont have this file then you have to comment the line CreateResourceFromFile and test ads will still work. i assume you are just starting out, so i suggest you to test your project from the test ad ids.
 
Last edited:
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Ok.
Do I have to place applications in the google store?

I will answer myself:
you do not need to install applications in the google store

Abhishek007p, Thank you very much for helping me.
 
Last edited:
Upvote 0

abhishek007p

Active Member
Licensed User
Longtime User
first make a sample admob example for testing. once you can see the test ads, you integrate the code into your main project.

you need to login to admob and start a new ad project and get json file and ad-id that you can use. you dont need to upload the app first.

adding ads should be done at the last steps, so unless you have a app ready, dont be in a hurry in adding ads.
 
Last edited:
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Success, there were no SDK packages. After installing the packages everything works fine
 
Last edited:
Upvote 0
Top