Android Studio Canary 3.4 Canary 4:错误:功能插件不支持variant.getApplicationId()

Vin*_*nce 5 android gradle android-studio build.gradle android-gradle-plugin

由于我在新的Android Studio 3.4 Canary 4上更新了我的项目,因此 gradle 同步失败,因为:

ERROR: variant.getApplicationId() is not supported by feature plugins as it cannot handle delayed setting of the application ID. Please use getApplicationIdTextResource() instead.
Affected Modules: base
Run Code Online (Sandbox Code Playgroud)

我以前在 Canary 3 上使用过,它运行良好。

该项目是一个多功能应用程序,包括一个即时应用程序。

Gradle 版本是 gradle-5.0-milestone-1-all

我的项目级 build.gradle

buildscript {

    ext.kotlin_version = '1.3.10'

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0-alpha04'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07'
    }

}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ext {

    compileSdkVersion = 28
    minSdkVersion = 16
    targetSdkVersion = 28

    appVersionCode = 5
    appVersion = "2.0.0-dev01"

}
Run Code Online (Sandbox Code Playgroud)

基础构建.gradle

apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'jacoco'
apply plugin: 'androidx.navigation.safeargs'

android {

    def yo = rootProject

    compileSdkVersion yo.compileSdkVersion

    baseFeature true

    defaultConfig {
        minSdkVersion yo.minSdkVersion
        targetSdkVersion yo.targetSdkVersion
        versionCode yo.appVersionCode
        versionName yo.appVersion
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary true
        multiDexEnabled true
    }

    buildTypes {
        debug {
            testCoverageEnabled !project.hasProperty('android.injected.invoked.from.ide')
            multiDexKeepFile file('multidex-config.txt')
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            multiDexKeepFile file('multidex-config.txt')
        }
    }

    dataBinding {
        enabled = true
    }

    lintOptions {
        disable "InvalidPackage"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

}

repositories {
    mavenCentral()
    google()
}

dependencies {

    application project(':app')
    feature project(':module1')

    [...]

}
Run Code Online (Sandbox Code Playgroud)

应用程序构建.gradle

apply plugin: 'com.android.application'

android {

    def yo = rootProject
    compileSdkVersion yo.compileSdkVersion

    defaultConfig {
        applicationId "com.package.name"
        minSdkVersion yo.minSdkVersion
        targetSdkVersion yo.targetSdkVersion
        versionCode yo.appVersionCode
        versionName yo.appVersion
        multiDexEnabled true
    }

    buildTypes {
        debug {
            applicationIdSuffix ".dev"
            splits.abi.enable = false
            splits.density.enable = false
            aaptOptions.cruncherEnabled = false

        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {

    implementation project(':module1')
    implementation project(':base')

    implementation 'com.android.support:multidex:1.0.3'

}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

我尝试在没有依赖项的情况下同步我的项目,但它也不起作用。

我还尝试使缓存无效并重新启动但没有效果。

根据错误日志,问题出在基础 build.gradle 文件中,但我不知道是什么问题。

预先感谢您的帮助!

Vin*_*nce 4

好吧,我发现了这个问题。

这是失败的安全参数导航插件

apply plugin: 'androidx.navigation.safeargs'
Run Code Online (Sandbox Code Playgroud)

如果我删除此行,该项目能够同步,但无法构建导航安全参数中缺少的类的原因。

Android Studio 3.4 Canary 4 中的导航插件在 baseFeature build.gradle 文件中应用时存在错误。

我将为此发布一个新问题。