firebasebuild.gradlecrashlyticsaws-codebuildcrashlytics-android

Firebase crashlytics mapping file is not uploading on a Ubuntu AWS container


I recently migrated to firebase-crashlytics-gradle from the deprecated Fabric library. It works properly on the local machine with these commands:

chmod +x ./gradlew
./gradlew clean
./gradlew assembleApplicationQa appDistributionUploadApplicationQa --debug

however, this is not working on the ubuntu container in the code build pipeline on AWS. The error that is showing is this one:

* What went wrong:
00:32:26.407 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution 
failed for task ':app:uploadCrashlyticsMappingFileApplicationQa'.
00:32:26.407 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > 
java.io.FileNotFoundException: 
/codebuild/output/src160981101/src/application/app/build/outputs/mapping/application/qa/mapping.txt 
(No such file or directory)
00:32:26.407 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 

I found that on the local there is a process in that task that is not happening con the ubuntu container: that is this one which seems like is reaching the Crashlytics server and uploads the file properly:

18:58:46.217 [DEBUG] [com.google.firebase.crashlytics] Uploading Mapping File [mappingFile: /Users/carlos/Desktop/Repo/Applicationandroid/Application/app/build/outputs/mapping/Application/qa/mapping.txt; mappingFileId: 764dc9b417f249f08823552e8e240186;packageName: com.Application.android.qa; googleAppId: 1:775166595613:android:604478ccade98840]
18:58:46.218 [DEBUG] [com.google.firebase.crashlytics] Zipping mapping file: /Users/carlos/Desktop/Repo/Applicationandroid/Application/app/build/outputs/mapping/Application/qa/mapping.txt -> /Users/carlos/Desktop/Repo/Applicationandroid/Application/app/build/crashlytics/ApplicationQa/mappings/764dc9b417f249f08823552e8e240186.gz
18:58:46.697 [DEBUG] [com.google.firebase.crashlytics] PUT file: /Users/carlos/Desktop/Repo/Applicationandroid/Application/app/build/crashlytics/ApplicationQa/mappings/764dc9b417f249f08823552e8e240186.gz to URL: https://firebasecrashlyticssymbols.googleapis.com/v1/project/-/app/1:775166595613:android:604478ccade98840/upload/java/764dc9b417f249f08823552e8e240186
18:58:46.698 [DEBUG] [com.google.firebase.crashlytics] PUT headers:
18:58:46.698 [DEBUG] [com.google.firebase.crashlytics]  User-Agent = crashlytics-gradle/2.0.0
18:58:46.698 [DEBUG] [com.google.firebase.crashlytics]  X-CRASHLYTICS-API-CLIENT-TYPE = crashlytics-gradle
18:58:46.698 [DEBUG] [com.google.firebase.crashlytics]  X-CRASHLYTICS-API-CLIENT-VERSION = 2.0.0
18:58:46.698 [DEBUG] [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: default
18:58:46.698 [DEBUG] [org.apache.http.client.protocol.RequestAuthCache] Auth cache not set in the context
18:58:46.699 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection request: [route: {s}->https://firebasecrashlyticssymbols.googleapis.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
18:58:46.699 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection leased: [id: 8][route: {s}->https://firebasecrashlyticssymbols.googleapis.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
18:58:46.699 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {s}->https://firebasecrashlyticssymbols.googleapis.com:443
18:58:46.759 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to firebasecrashlyticssymbols.googleapis.com/142.250.113.95:443
18:58:46.759 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Connecting socket to firebasecrashlyticssymbols.googleapis.com/142.250.113.95:443 with timeout 0
18:58:46.811 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Enabled protocols: [TLSv1.2, TLSv1.1, TLSv1]
18:58:46.811 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
18:58:46.811 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Starting handshake
18:58:46.870 [DEBUG] [jdk.event.security] ValidationChain: 7087067, 1544128074,234213421
18:58:46.925 [DEBUG] [jdk.event.security]  TLSHandshake: firebasecrashlyticssymbols.googleapis.com:443, TLSv1.2, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 1528437816
18:58:46.925 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Secure session established
18:58:46.925 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory]  negotiated protocol: TLSv1.2
18:58:46.925 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory]  negotiated cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
18:58:46.926 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory]  peer principal: CN=upload.video.google.com, O=Google LLC, L=Mountain View, ST=California, C=US
18:58:46.926 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory]  peer alternative names: [upload.video.google.com, *.clients.google.com, *.docs.google.com, *.drive.google.com, *.gdata.youtube.com, *.googleapis.com, *.photos.google.com, *.upload.google.com, *.upload.youtube.com, *.youtube-3rd-party.com, upload.google.com, upload.youtube.com, uploads.stage.gdata.youtube.com]
18:58:46.926 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory]  issuer principal: CN=GTS CA 1O1, O=Google Trust Services, C=US
18:58:46.926 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 192.168.0.9:61946<->142.250.113.95:443
18:58:46.926 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request PUT /v1/project/-/app/1:775166595613:android:604478ccade98840/upload/java/764dc9b417f249f08823552e8e240186 HTTP/1.1
18:58:46.926 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Target auth state: UNCHALLENGED
18:58:46.926 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED
18:58:51.688 [LIFECYCLE] [org.gradle.process.internal.health.memory.MemoryManager] 
18:58:51.688 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting OS memory status event {Total: 17179869184, Free: 6186242048}
18:58:51.688 [DEBUG] [org.gradle.launcher.daemon.server.health.LowMemoryDaemonExpirationStrategy] Received memory status update: {Total: 17179869184, Free: 6186242048}
18:58:51.688 [DEBUG] [org.gradle.process.internal.health.memory.MemoryManager] Emitting JVM memory status event {Maximum: 3817865216, Committed: 3571974144}
18:58:48.233 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] 
18:58:48.233 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :app:uploadCrashlyticsMappingFileAppicationQa
18:58:53.416 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection can be kept alive indefinitely
18:58:53.416 [DEBUG] [com.google.firebase.crashlytics] PUT response: [reqId=null] 200
18:58:53.416 [INFO] [com.google.firebase.crashlytics] Mapping file uploaded: /Users/hernandez/Desktop/Repo/Appicationandroid/Appication/app/build/outputs/mapping/Appication/qa/mapping.txt
18:58:53.416 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute uploadMappingFile for :app:uploadCrashlyticsMappingFileApplicationQa'
18:58:53.417 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute uploadMappingFile for :app:uploadCrashlyticsMappingFileApplicationQa' completed
18:58:53.417 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
18:58:53.417 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:uploadCrashlyticsMappingFileApplicationQa'
18:58:53.417 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Task :app:uploadCrashlyticsMappingFileApplicationQa'
18:58:53.417 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :app:uploadCrashlyticsMappingFileApplicationQa' completed
18:58:53.417 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :app:uploadCrashlyticsMappingFileApplicationQa (Thread[Task worker for ':',5,main]) completed. Took 7.201 secs.
 ':': acquired lock on root.1.26

As you can see the process uploads the file and then completes, however in the ubuntu container it doesn't happen:

00:32:25.697 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :app:uploadCrashlyticsMappingFileApplicationQa (Thread[Task worker for ':' Thread 7,5,main]) started.
00:32:25.697 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] 
00:32:25.697 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] > Task :app:uploadCrashlyticsMappingFileApplicationQa FAILED
00:32:25.697 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :app:uploadCrashlyticsMappingFileApplicationQa' started
00:32:25.697 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':app:uploadCrashlyticsMappingFileApplicationQa'
00:32:25.697 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Putting task artifact state for task ':app:uploadCrashlyticsMappingFileApplicationQa' into context took 0.0 secs.
00:32:25.697 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':app:uploadCrashlyticsMappingFileApplicationQa' is up-to-date
00:32:25.697 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Task ':app:uploadCrashlyticsMappingFileApplicationQa' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
00:32:25.697 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':app:uploadCrashlyticsMappingFileApplicationQa'.
00:32:25.697 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute uploadMappingFile for :app:uploadCrashlyticsMappingFileApplicationQa' started
00:32:25.701 [DEBUG] [com.google.firebase.crashlytics] Getting appId from output of the Google Services plugin at /codebuild/output/src160981101/src/Application/app/build/generated/res/google-services/Application/qa/values/values.xml
00:32:25.733 [DEBUG] [com.google.firebase.crashlytics] Found Google appId: 1:775166595613:android:604478ccade232432
00:32:25.741 [DEBUG] [com.google.firebase.crashlytics] Uploading Mapping File [mappingFile: /codebuild/output/src160981101/src/Application/app/build/outputs/mapping/Application/qa/mapping.txt; mappingFileId: 140f7e5865d146cdb1c49d4eae9d82b7;packageName: com.Application.android.qa; googleAppId: 1:775166595613:android:604478ccade232432]
00:32:25.742 [DEBUG] [com.google.firebase.crashlytics] Zipping mapping file: /codebuild/output/src160981101/src/Application/app/build/outputs/mapping/Application/qa/mapping.txt -> /codebuild/output/src160981101/src/Application/app/build/crashlytics/ApplicationQa/mappings/140f7e5865d146cdb1c49d4eae9d82b7.gz
00:32:25.742 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Execute uploadMappingFile for :app:uploadCrashlyticsMappingFileApplicationQa'
00:32:25.742 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Execute uploadMappingFile for :app:uploadCrashlyticsMappingFileApplicationQa' completed
00:32:25.743 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
00:32:25.743 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':app:uploadCrashlyticsMappingFileApplicationQa'
00:32:25.743 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Completing Build operation 'Task :app:uploadCrashlyticsMappingFileApplicationQa'
00:32:25.743 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Task :app:uploadCrashlyticsMappingFileApplicationQa' completed
00:32:25.743 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :app:uploadCrashlyticsMappingFileApplicationQa (Thread[Task worker for ':' Thread 7,5,main]) completed. Took 0.045 secs.

So I really don't know what if going on, but this is breaking the pipeline because is not compiling, if I set the flag on the Gradle file of mappingFileUploadEnabled to false:

mappingFileUploadEnabled false

the project is compiling successfully but, when it is set to true it is not.

So seems like the problem is firebase is not reaching its server but I don't know why, the container doesn't have any IP restriction to firebase

Thank you for your help I really appreciate it!


Solution

  • After several days of doing this, I discovered that the problem is related to Crashlytics and the Gradle version if you use this configuration:

    1. Docker Image for building the project: standard/ubuntu4:0 from this place

    2. Gradle version: 4.10.3 and android Gradle plugin 3.3.3

    3. Any version of Crashlytics from 17.0.0 and up

    4. Progurad must be enabled and the flag to upload the mapping file to Crashlycts must be true

    Then run the project and the project will crash.

    The solution is to upgrade the Gradle version to 5.1.1 and the project will run properly, a code example is here

    You can see through the comments, how the project evolved.