What is the <module>/release/output.json generated by Android Studio

ouput.json file is kind of a metadata file for your generated APK. This file is generated due to various reasons. I have found some of them, which might not list all of the use cases, but here's the list:

  1. Generated when Generate Signed APK is executed
  2. Generated for AndroidManifest.xml file under

    {module}/build/intermediates/manifest/androidTest/debug/ouput.json
    
  3. It is not generated for Unit tests, but only generated for AndroidTests (which depends on Android framework to be executed)

  4. The file output.json generated for AndroidManifest.xml at above specified location is slightly different from the one generated for APK as you have mentioned.
  5. As you can see the properties described by output.json file is very similar to the properties that we usually specify in our build.gradle file, so it must be used & required for build process to work successfully (or it might be getting generated as a result of successful build and extracting of required properties from build.gradle).

Upon this, we can conclude that it surely depends upon Android framework to be generated & it is related to be describing the details/info about the APK or Manifest file.

  • I have personally tried to Google & find a proper answer to this even on Android Developers website, but it seems nothing is documented about this file in detail.

  • I have checked several projects on GitHub & checked .gitignore file for the same, I couldn't find any of the similar output.json file in any of the projects hosted on GitHub. So it should be a good practice to exclude them in your commits.

  • In short, this file is a descriptive file containing important metadata about project. It must be there for a reason. I would suggest you not to mess with it as we don't know what it may result in.


In Android Studio 4.0 a new file appears after succesful build (apk or aab): app/release/output-metadata.json. In order not to annoy with it in Git, just add to <project>/.gitignore:

# Metadata created after successful build.
/app/release/output-metadata.json

For anyone who want to disable this feature, here is my trick.
It simply delete output.json after generation.

applicationVariants.all { variant ->
    variant.assemble.doLast {
        def buildType = variant.buildType.name
        def outputPath = ""

        // If you use separated output path for both condition.
        if (buildType == "debug") {
            outputPath = "${buildDir}/outputs/apk"
        }
        if (buildType == "release") {
            outputPath = "${rootDir}/apk"
        }
        println "outputPath:" + outputPath

        delete "${outputPath}/yourFlavor1/${buildType}/output.json"
        delete "${outputPath}/yourFlavor2/${buildType}/output.json"
        delete "${outputPath}/yourFlavor.../${buildType}/output.json"
    }
}

Android studio 3.0 is responsible for this file. You don't need to worry about the output.json file.

Let me explain this to you:

For older versions, what Android Studio did was generate a signed APK and put it in the "output" folder. Even If you had multiple flavour dimensions for your APK, all of them could be located at the same directory, which was the output folder. From the latest release of Android Studio 3.0 (canary and stable), they have organized this file structure. For every flavour dimension, whenever you sign an APK, it will have a separate folder with a corresponding output.json file in it. This file is actually nothing but a description of the source APK. As you can see, the file you shared here is describing the released APK.