microg/GmsCore · error · IOException

Failed to download file: HTTP response code ${connection.res

Error message

Failed to download file: HTTP response code ${connection.responseCode}

What it means

Download failure in DownloadManager.startDownload: the HTTP response code for the module file was not a success code (connection.responseCode embedded in the message), so the module download for the given destination file failed.

Source

Thrown at vending-app/src/main/kotlin/com/google/android/finsky/DownloadManager.kt:184

        Log.d(TAG, "Download for module $moduleName has been canceled.")
        downloadingRecord[moduleName]?.cancel(true)
        shouldStops = true
        notifyBuilderMap[moduleName]?.setOngoing(false)
        NotificationManagerCompat.from(context).cancel(NOTIFICATION_ID)
    }

    private fun startDownload(moduleName: String, downloadLink: String, destinationFile: File, downloadData: DownloadData) {
        val packData = downloadData.getModuleData(moduleName)
        val uri = Uri.parse(downloadLink).toString()
        val connection = URL(uri).openConnection() as HttpURLConnection
        var bytes: Long = 0
        try {
            connection.requestMethod = "GET"
            connection.connectTimeout = 20000
            connection.readTimeout = 20000
            connection.connect()
            if (connection.responseCode != HttpURLConnection.HTTP_OK) {
                throw IOException("Failed to download file: HTTP response code ${connection.responseCode}")
            }
            if (destinationFile.exists()) {
                destinationFile.delete()
            } else destinationFile.parentFile?.mkdirs()

            connection.inputStream.use { input ->
                FileOutputStream(destinationFile).use { output ->
                    val buffer = ByteArray(4096)
                    var bytesRead: Int
                    while (input.read(buffer).also { bytesRead = it } != -1) {
                        if (shouldStops) {
                            Log.d(TAG, "Download interrupted for module: $moduleName")
                            downloadData.updateDownloadStatus(moduleName, AssetPackStatus.CANCELED)
                            return
                        }
                        output.write(buffer, 0, bytesRead)
                        bytes += bytesRead.toLong()
                        downloadData.incrementModuleBytesDownloaded(moduleName, bytesRead.toLong())

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Retry the download — server errors are often transient
  2. Verify the download link is valid and not expired
  3. Check connectivity and notify the user, cancelling the progress notification on permanent failure
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at vending-app/src/main/kotlin/com/google/android/finsky/DownloadManager.kt:184 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/79f37ce6451e0dbf. Report an issue: GitHub.