Android Question Firestore - compile error

Andrew (Digitwell)

Active Member
Licensed User
Hi @DonManfred ,
I have just got some time to try the firestore again.

I tried compiling the following code.
B4X:
    Activity.LoadLayout("page")
    fs.Initialize("Firestore",True)
    Dim driver As CollectionReference = fs.collection("cities","CitiesCollection")
    If driver <> Null Then
        Log("setting to get all cities")
'        driver.whereEqualTo("id","DonManfred").limit(1).fetch("DriverFetch")
        wait for DriverFetch_Snapshot(snap As QuerySnapshot)
        Log($"Driver_Snapshot(${snap.Size},${snap})"$)
        Dim meta As SnapshotMetadata = snap.Metadata
        Dim documents As List = snap.Documents
        'Log(documents)
        If documents.IsInitialized Then
            If documents.Size > 0 Then
                For i = 0 To documents.Size-1
                    Dim docsnap As DocumentSnapshot = documents.Get(i)
                    CustomListView1.AddTextItem("Document: #"&i&": "&docsnap.Id,0)
                Next
            End If
        Else
            Log("Snapshot does not contain a list of Documents...")
        End If
    End If

and it gave me this error:
B4A Version: 8.80
Parsing code. (0.04s)
Building folders structure. (0.26s)
Compiling code. (0.42s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Generating R file. (0.55s)
Compiling debugger engine code. (1.80s)
Compiling generated Java code. (2.44s)
Convert byte code - optimized dex. Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractMessageLite;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractMessageLite$Builder;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractMessageLite$Builder$LimitedInputStream;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractParser;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/AbstractProtobufList;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/BooleanArrayList;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/ByteBufferWriter;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/ByteOutput;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/protobuf/ByteString;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:370)
at com.android.dx.command.dexer.Main.runDx(Main.java:291)
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:684)
... 4 more

I have included all of the additional jars and patched my SDK to include com.google.protobuf

#AdditionalJar: com.google.android.gms:play-services-auth
#AdditionalJar: com.google.android.gms:play-services-base
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-auth
#AdditionalJar: com.google.firebase:firebase-database
#AdditionalJar: com.google.firebase:firebase-core
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-firestore
#AdditionalJar: com.google.gms:google-services
#AdditionalJar: grpc-core-1.20.0.jar
#AdditionalJar: grpc-protobuf-1.20.0.jar
#AdditionalJar: grpc-okhttp-1.20.0.jar
#AdditionalJar: grpc-android-1.20.0.aar
#AdditionalJar: opencensus-api-0.20.0.jar
#AdditionalJar: grpc-stub-1.20.0.jar
#AdditionalJar: grpc-protobuf-lite-1.20.0.jar
#additionaljar: protobuf-lite-3.0.1.jar
#AdditionalJar: opencensus-contrib-http-util-0.20.0.jar
#AdditionalJar: opencensus-contrib-grpc-metrics-0.20.0.jar
#AdditionalJar: grpc-context-1.20.0.jar
#AdditionalJar: glide-3.8.0.jar
#AdditionalJar: guava-27.1-android.jar
#ExcludeClasses: com.google.guava:guava-jdk5
 

Andrew (Digitwell)

Active Member
Licensed User
It seems a bit better , but now I get the following:

B4X:
B4A Version: 8.80
Parsing code.    (0.05s)
Building folders structure.    (0.05s)
Compiling code.    (1.32s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (3.39s)
Generating R file.    (0.73s)
Compiling debugger engine code.    (2.45s)
Compiling generated Java code.    (2.70s)
Convert byte code - optimized dex.    Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/common/util/concurrent/ListenableFuture;
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
2 errors; aborting
 

DonManfred

Expert
Licensed User
hmm... i´m a bit lost now
i just tried my example and it is compiling. Dammit. Did i patched more in the SDK then i remember what i did?

I started patching the SDK last year when Firestore was still in Beta. I´ll setup a complete new SDK and new B4A Installation and build the setup again tomorrow.
 

Andrew (Digitwell)

Active Member
Licensed User
I increased MaxRamforDex to 4096 which seems to have fixed the GC overhead problem.

Now I get -
B4X:
B4A Version: 8.80
Parsing code.    (0.06s)
Building folders structure.    (0.10s)
Compiling code.    (0.78s)
Compiling layouts code.    (0.05s)
Organizing libraries.    (3.15s)
Generating R file.    (0.68s)
Compiling debugger engine code.    (2.36s)
Compiling generated Java code.    (3.71s)
Convert byte code - optimized dex.    Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/common/util/concurrent/ListenableFuture;
1 error; aborting
A bit of research brought me to this page :
https://stackoverflow.com/questions...le-common-util-concurrent-l?noredirect=1&lq=1

which suggested that com.google.guava:listenablefuture is excluded.
.. need to add this for the firebase component implementation ("android.arch.work:work-firebase:$archWorkerRuntimeVersion") { exclude group: 'com.google.guava', module: 'listenablefuture' }
so I updated the exclude Classes line as follows:
B4X:
#ExcludeClasses: com.google.guava:guava-jdk5, com.google.guava:listenablefuture
and the same error occurs. so still stuck.

I wonder if the exclusion needs to be added at the java library level.
 

DonManfred

Expert
Licensed User
and the same error occurs. so still stuck.
interestingly it does not happen for me.
i had a lot of fights with the "listenablefuture" in the past

As written: i´ll setup some things new today to start with a blank b4a installation. And hopefully run into the same problem and able to fix it.
 

DonManfred

Expert
Licensed User
Try this set

B4X:
#MultiDex: true ' NEW

#AdditionalJar: com.google.android.gms:play-services-auth
#AdditionalJar: com.google.android.gms:play-services-base
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-auth
#AdditionalJar: com.google.firebase:firebase-database
#AdditionalJar: com.google.firebase:firebase-core
#AdditionalJar: com.google.firebase:firebase-common
#AdditionalJar: com.google.firebase:firebase-firestore
#AdditionalJar: com.google.gms:google-services
#AdditionalJar: grpc-core-1.20.0.jar
#AdditionalJar: grpc-protobuf-1.20.0.jar
#AdditionalJar: grpc-okhttp-1.20.0.jar
#AdditionalJar: grpc-android-1.20.0.aar
#AdditionalJar: opencensus-api-0.20.0.jar
#AdditionalJar: grpc-stub-1.20.0.jar
#AdditionalJar: grpc-protobuf-lite-1.20.0.jar
#AdditionalJar: opencensus-contrib-http-util-0.20.0.jar
#AdditionalJar: opencensus-contrib-grpc-metrics-0.20.0.jar
#AdditionalJar: grpc-context-1.20.0.jar
#AdditionalJar: glide-3.8.0.jar
#AdditionalJar: guava-27.1-android.jar
#AdditionalJar: com.google.guava:listenablefuture ' NEW
#ExcludeClasses: com.google.guava:guava-jdk5
 

Andrew (Digitwell)

Active Member
Licensed User
Manfred,
I already had the MultiDex line.
I added the other line.

I still get exactly the same error message.

I also found this whilst searching.

https://mvnrepository.com/artifact/com.google.guava/listenablefuture

Guava ListenableFuture Only
An empty artifact that Guava depends on to signal that it is providing ListenableFuture -- but is also available in a second "version" that contains com.google.common.util.concurrent.ListenableFuture class, without any other Guava classes. The idea is: - If users want only ListenableFuture, they depend on listenablefuture-1.0. - If users want all of Guava, they depend on guava, which, as of Guava 27.0, depends on listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.
 

DonManfred

Expert
Licensed User
I still get exactly the same error message.
It still is working for me :-(
I setupped a completely new SDK yesterday (ready to run sdk). Updated all recommended items, added the "Patch" to the SDK (like mentioned in private).
It works fine for me to compile and run my Example. Strange

Though i am using a special Structure in my Collection (using the Driver and Car classes). Maybe this is part of the problem? hmmm...

Can you maybe extract a part of your collections so i can build a test in my Database using the same structure?
 

Andrew (Digitwell)

Active Member
Licensed User
Hi Manfred,
The problem is that it is not getting that far. The build process does not complete. I will zip up the complete app and send to you in private.
 

Ferdari

Active Member
Licensed User
How do you solved this? i'm stuck on the same

i updated the Firebase Messaging & Firebase Ads to the latest version but then it stay asking for missing Maven modules, i solved most with your older threads(@DonManfred ), but now can't solve Guava listenablefuture, it isn't available on the SDK manager.
 
Top