Android Studio:如何为发行版本设置注释处理器选项

时间:2019-06-19 13:32:21

标签: java android android-studio gradle annotation-processing

我正在使用Android Studio进行Android Java项目。我需要针对发行版本自定义注释处理器选项。我的Gradle配置文件是:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {
        config {
            keyAlias System.getenv("GRADLE_KEYSTORE_ALIAS")
            keyPassword System.getenv("GRADLE_KEYSTORE_ALIAS_PASSWORD")
            storeFile file(System.getenv("GRADLE_KEYSTORE_FILE"))
            storePassword System.getenv("GRADLE_KEYSTORE_PASSWORD")
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "it.dummy.projeca"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 10215
        versionName "1.2.15"
"androidx.activity_splash_screen.runner.AndroidJUnitRunner"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'


        buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L"
        buildConfigField "boolean", "LOG_ENABLED", "true"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "kripton.androidx": "true",
                        "kripton.debug"   : "false",
                        "kripton.log"     : "true",
                ]
            }
        }
    }
    buildTypes {
        release {
            buildConfigField "boolean", "LOG_ENABLED", "false"

            zipAlignEnabled true
            minifyEnabled true
            proguardFiles System.getenv("GRADLE_PROGUARD_CONFIG_FILE"),
                          'proguard-rules.pro'

        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    // removed for clearity
    ...
}

apply plugin: 'com.google.gms.google-services'

我试图将javaCompileOptions部分复制到发布部分,但是我收到了Could not find method javaCompileOptions() for arguments ...

在发布模式下,我需要kripton.log = false(在Debug模式下是true)。我如何实现这个目标?

提前发送

0 个答案:

没有答案