Android Question Firestore - compile error

Discussion in 'Android Questions' started by Andrew (Digitwell), May 2, 2019.

  1. Andrew (Digitwell)

    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.
    Code:
    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
     
  2. DonManfred

    DonManfred Expert Licensed User

    try remove this line.

    Based on the error something is referenced double.

    Om my example i am not using this line
     
  3. Andrew (Digitwell)

    Andrew (Digitwell) Active Member Licensed User

    It seems a bit better , but now I get the following:

    Code:
    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
     
  4. DonManfred

    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.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Looks like you need to increase MaxRamForDex.
     
  6. Andrew (Digitwell)

    Andrew (Digitwell) Active Member Licensed User

    I increased MaxRamforDex to 4096 which seems to have fixed the GC overhead problem.

    Now I get -
    Code:
    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.
    so I updated the exclude Classes line as follows:
    Code:
    #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.
     
  7. DonManfred

    DonManfred Expert Licensed User

    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.
     
  8. DonManfred

    DonManfred Expert Licensed User

    Try this set

    Code:
    #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
     
  9. Andrew (Digitwell)

    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

     
  10. DonManfred

    DonManfred Expert Licensed User

    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?
     
  11. Andrew (Digitwell)

    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.
     
    DonManfred likes this.
  12. DonManfred

    DonManfred Expert Licensed User

    Note that you will need to add my sha-1 signature to your project too. I´ll send in private ;-)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice