Android Question Problem with "#additionaljar: com.android.support:support-v4" and Google Maps

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I have a little problem with one of my apps that uses a notification.
My app is a three years old app and I used standard notifications with this code in a service module:

B4X:
    Dim nNotif As Notification
    nNotif.Initialize
    nNotif.Vibrate = True
    nNotif.Icon = "icon"
    nNotif.AutoCancel = False
    nNotif.SetInfo("Notification", "The service started", Main)
    nNotif.Notify(123)
    Service.StartForeground(123, nNotif)

I was using Google Maps with no problem as described in this tutorial.
Recently I watched Erel's post for B4A 8.0 (I am using B4A 7.80) for the backward compatibility problem in new Androids in notifications. Searching the forum I found this tutorial for version safe notifications and I decided to use Erel's code. I added the Notification Builder library and changed my code as follows:

B4X:
    Dim nNotif As Notification
    nNotif.Initialize
    nNotif = CreateNotification("Notification", "The service started", "icon", Main, True, True)
    nNotif.Notify(123)
    Service.StartForeground(123, nNotif)

I added also the "#additionaljar: com.android.support:support-v4" in my Main activity and updated all the resources with B4A sdk Manager.

When I tried to compile I get this error:

B4A Version: 7.80
Parsing code. (0.03s)
Compiling code. (0.79s)

ObfuscatorMap.txt file created in Objects folder.
Compiling layouts code. (0.15s)
Organizing libraries. (1.59s)
Generating R file. (2.83s)
Compiling generated Java code. Error
B4A line: 411
gmap.AnimateCamera(cp)
javac 1.8.0_121
src\dhqi\besafe\android\settings.java:907: error: package com.google.android.gms.maps.model does not exist
mostCurrent._vvvvvvvvvvvv1.AnimateCamera((com.google.android.gms.maps.model.CameraPosition)(_cp.getObject()));

If I remove the reference #additionaljar: com.android.support:support-v4 and the Notification Builder library and change my code back to what it was everything works fine.
I also tried to add the reference #additionaljar: com.android.support:support-v4 without adding the Notification Builder library and without changing my code and even if I just add it I get the same error.
Any Ideas?

Thanks in advance
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Yes Erel. I do.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
No Erel, I have impemented the tutorial you see in the first post under the word "this" (the app is 3 years old).
I will give it a try and I will let you know. Now I am away from my computer. When I go back home I 'll test it. Thanks...
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
It works perfect now. Thanks a lot Erel. I wanted to ask you another thing though.

I have an Android 4.1.2 Device. If I add the following code to my manifest as you suggest
in this post:
https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/

The application does not even start and execution breaks without any logs (with #BridgeLogger).
Is my android device responsible or am I doing something wrong?


B4X:
'************ 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) ************
 
Upvote 0
Top