Search code examples
androidmoduleandroid-gradle-pluginbytecode

How to set byteCode level when creating a android library module in android studio 4.1.1?


This image shows the pop up dialog when we create a new module from the list of module types. Here i have selected Android Library. This image shows the pop up dialog when we create a new module from the list of module types.


Solution

  • I think that this setting represents the compileOptions and kotlinOptions.

    https://developer.android.com/studio/write/java8-support

    For example, if you set ByteCode Level to 6, the compileOptions and kotlinOptions in the build.gradle of the module you created will look like this.

    android {
        .
        .
        .
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_6
            targetCompatibility JavaVersion.VERSION_1_6
        }
        kotlinOptions {
            jvmTarget = '1.6'
        }
    }
    

    Also, if ByteCode Level is set to 8, the following will be shown.

    android {
        .
        .
        .
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = '1.8'
        }
    }