android - versionName 不能直接在 mergedFlavor 上设置,更新到 gradle 5.1.1

标签 android groovy build android-gradle-plugin

我已经从 3.1.1 更新到 Gradle 发行版 5.1.1,它涉及很多更改,包括更新 androidX 支持库。出于某种原因,build 一直未能要求更改 versionName 在 merged flavor 中的设置方式。我无法弄清楚我到底错过了什么,已经添加了 gradle 构建结果建议的代码。

构建.gradle

buildscript {
ext.kotlin_version = '1.3.40'
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://nexus.dminc-gtc.com/nexus/content/groups/public/' }
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.google.com' }
    maven { url 'https://repo.spring.io/libs-milestone' }

    mavenLocal()
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    maven { url "https://plugins.gradle.org/m2/" }
    google()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    //annotationProcessor  'com.neenbedankt.gradle.plugins:android-apt:1.4'
    classpath 'com.dminc.gradle:android-release-plugin:1.0.0'
    classpath 'io.fabric.tools:gradle:1.27.1'
    classpath 'com.github.triplet.gradle:play-publisher:1.1.5'
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.0.1'
    classpath 'com.github.alexfu:androidautoversion:3.0.2'
 }
}

  repositories {
  maven { url 'https://maven.fabric.io/public' }
  maven { url 'https://nexus.dminc-gtc.com/nexus/content/groups/public/' }
  mavenLocal()
  mavenCentral()
  jcenter()
  flatDir {
      dirs 'libs'
  }
  maven { url "https://jitpack.io" }


  maven { url 'http://maven.localytics.com/public' }
  maven { url 'https://maven.google.com' }
  maven { url 'https://repo.spring.io/libs-milestone' }

  maven {
      url 'https://maven.google.com/'
      name 'Google'
  }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'android-apt'
apply plugin: 'android-release-plugin'
apply plugin: 'com.google.gms.google-services'
apply from: 'checkstyle.gradle'
apply from: 'pmd.gradle'
apply from: 'findbugs.gradle'
apply plugin: 'com.github.triplet.play'
apply from: 'sonar.gradle'
apply plugin: 'com.github.alexfu.androidautoversion'

ext.androidAnnotationsVersion = '4.6.0'

android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
    // These are applied to the manifest, to prevent nasty compat modes, use the latest you can.
    minSdkVersion 19
    targetSdkVersion 28
    renderscriptTargetApi 19
    renderscriptSupportModeEnabled true
}

releaseConfig {
    // Set to true to add the version number from the apk name (default is false)
    addVersionToApk false
    // No default for propertyFile, you HAVE to specify it, it will be interpreted by the plugin as follow: [root_dir]/[propertyFile]
    propertyFile "version.properties"
}


flavorDimensions 'white_label', 'server'
productFlavors {
    newmoove {
        // Assigns this product flavor to the "version" flavor dimension.
        // This property is optional if you are using only one dimension.
        dimension "white_label"
        applicationId 'com.app.newmoove'
        manifestPlaceholders = [crashlyticsApiKey: "*******************",
                                facebookAppId    : "*************"]


    }
    wexer {
        // Assigns this product flavor to the "version" flavor dimension.
        // This property is optional if you are using only one dimension.
        dimension "white_label"
        applicationId 'com.app.wexer'
        manifestPlaceholders = [crashlyticsApiKey: "*********************",
                                facebookAppId    : "*************"]


    }
    customfit {
        // Assigns this product flavor to the "version" flavor dimension.
        // This property is optional if you are using only one dimension.
        dimension "white_label"
        applicationId 'com.appname.app'
        manifestPlaceholders = [crashlyticsApiKey: "**********************"]

    }
    dev {
        dimension "server"
        applicationIdSuffix ".devtest"
        versionNameSuffix "-dev"

    }
    integration {
        dimension "server"
        applicationIdSuffix ".integration"
        versionNameSuffix "-integration"

    }
    staging {
        dimension "server"
        applicationIdSuffix ".staging"
        versionNameSuffix "-staging"

    }
    live {
        dimension "server"

    }
}
// A lot of 3rd party libraries contain similar stuff.
packagingOptions {
    exclude 'LICENSE.*'
    exclude 'NOTICE.*'
    exclude 'META-INF/services/javax.annotation.processing.Processor'
}
lintOptions {
    quiet true
    abortOnError false
    ignoreWarnings true
}

applicationVariants.all { variant ->
    variant.outputs.each { output ->
        output.versionNameOverride = "5.0.1.91-5.0.1"
    }
  }
}

dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')
implementation(name: 'Android-ViewPagerIndicator', ext: 'aar')
implementation(name: 'Fontify-release', ext: 'aar')
implementation(name: 'HoloGraphLibrary-release', ext: 'aar')
implementation(name: 'slidingmenu-release', ext: 'aar')
implementation 'com.mani:ThinDownloadManager:1.3.0'
implementation 'com.github.johnkil.print:print:1.3.1'
implementation 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
implementation 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
implementation 'com.edmodo:rangebar:1.0.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'de.greenrobot:eventbus:2.4.1'
implementation 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
implementation 'com.path:android-priority-jobqueue:1.1.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.9.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.0'
implementation 'com.j256.ormlite:ormlite-android:5.0'
implementation 'com.github.gabrielemariotti.cards:library:1.9.1'
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.google.android.gms:play-services-analytics:11.2.0'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
implementation 'com.google.android.gms:play-services-location:11.2.0'
implementation 'com.google.android.gms:play-services-auth:11.2.0'
implementation 'com.google.android.gms:play-services-fitness:11.2.0'
implementation 'com.google.android.gms:play-services-ads:11.2.0'
implementation 'com.google.firebase:firebase-messaging:11.2.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'org.robolectric:robolectric:3.4'
implementation 'com.facebook.android:facebook-android-sdk:4.+'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
    transitive = true;
}
implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
// or 1.4-beta1
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
// or 1.4-beta1
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
// or 1.4-beta1
implementation 'com.localytics.android:library:5.4.0'
implementation 'com.github.tony19:timber-loggly:1.0.1'
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
implementation 'com.github.mmin18:realtimeblurview:1.1.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
implementation 'com.andkulikov:transitionseverywhere:1.7.5'
implementation 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
implementation 'net.danlew:android.joda:2.9.9'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation('com.devbrackets.android:exomedia:4.0.3') {
    exclude(module: 'support-v4')
    exclude(module: 'appcompat-v7')
}
implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M4'
implementation 'com.github.PhilJay:MPAndroidChart:v2.1.4'
implementation "org.androidannotations:androidannotations:${androidAnnotationsVersion}"
implementation "org.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
implementation "org.androidannotations:rest-spring-api:${androidAnnotationsVersion}"
implementation "org.androidannotations:rest-spring:${androidAnnotationsVersion}"
implementation "org.androidannotations:ormlite-api:${androidAnnotationsVersion}"
implementation "org.androidannotations:ormlite:${androidAnnotationsVersion}"
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation 'com.stripe:stripe-android:6.1.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation('androidx.cardview:cardview:1.0.0') {
    force = true
}
implementation 'jp.wasabeef:blurry:2.1.1'
implementation 'com.otaliastudios:nestedscrollcoordinatorlayout:1.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

//rx
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
implementation 'com.google.firebase:firebase-core:11.2.0'
implementation 'com.google.firebase:firebase-invites:11.2.0'

implementation group: 'com.neenbedankt.gradle.plugins', name: 'android-apt', version: '1.8'
}

无论我做什么,在构建项目时都无法通过以下错误。

enter image description here

最佳答案

在 build.gradle 中进行此更改(在错误窗口中建议)并进行干净的构建。

关于android - versionName 不能直接在 mergedFlavor 上设置,更新到 gradle 5.1.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56742072/

相关文章:

Android检测屏幕键盘的完成按键

java - 如何确保包含的子项目在 Gradle 中的主项目之前运行?

javascript - 使用 gulp 构建一个项目并且 requireJS 搞砸了

c++ - log4cplus 未解析的外部符号 LNK2001

Android ESC/POS 通过 WiFi 打印

android - node js和appium有什么关系?如何在两个不同的端口上运行到多个 appium 服务器实例?

android - 使用 JFrog Artifactory 的 Kotlin 多平台库

java - Groovy Java 交叉编译 instanceof

Groovy:为列表中的每个字符串添加前缀

groovy - Groovy 中的全局常量