Android Question Problem when running my app with Firebase push notifications

Almog

Active Member
Licensed User
Hello,

I tried to use Push notifications with Firebase, throe Erel's video tutorial.

When running in release mode, this error occurred at the compiler:

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurement;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/AppMeasurementContentProvider;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zza;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzaa;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzab;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzac;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzad;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzae;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/measurement/internal/zzaf;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:696)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
at com.android.dx.command.dexer.Main.runDx(Main.java:293)
at com.android.dx.command.dexer.Main.main(Main.java:249)
at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:688)
... 4 more



Does anybody know what the problem is and how to fix it?

Thanks in advance...
 

DonManfred

Expert
Licensed User
Longtime User
Post your manifestcode

Maybe post all libs you are using.

Best is to start implementing in a small project.

Also post all additionallibs lines you are using in your project
 
Upvote 0

Almog

Active Member
Licensed User
Post your manifestcode
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)
'End of default text.
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)

AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)

Maybe post all libs you are using.
Core (9.00)
Dialogs (4.01)
FirebaseAnalytics (1.02)
FirebaseNotifications (1.21)

JavaObject (2.05)
JSON (1.10)
OkHttp (1.22)
OkHttpUtils (2.82)
Phone (2.50)
RuntimePermissions (1.10)
StringUtils (1.12)
XUI (1.90)

Best is to start implementing in a small project.

Also post all additional libs lines you are using in your project

The problem happened only after adding Push Notifications option to my project. I tried compiling it before and it worked.

FirebaseMessaging service:
B4X:
#Region  Service Attributes
    #StartAtBoot: False
    
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
End Sub

Sub Service_Create
    fm.Initialize("fm")
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("general") 'you can subscribe to more topics
End Sub

Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)
    Dim n As Notification
    n.Initialize
    n.Icon = "icon"
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    n.Notify(1)
End Sub

Sub Service_Destroy

End Sub

Starter service:
B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public Provider As FileProvider
End Sub

Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    Provider.Initialize
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
End Sub

Sub Service_Start (StartingIntent As Intent)
    

End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy

End Sub


Thanks in advance...
 
Upvote 0

Almog

Active Member
Licensed User
Not sure why it happens. Are you sure that there isn't any other referenced library?

If you like you can send me the project to erel@basic4ppc.com and I'll try it here.
OK, thank you very much, I will now send it.
By the way, earlier I tried creating an example project, of using firebase notifications in it, and it didn't work, also.
I will now send it...
 
Upvote 0
Top