versionName不能直接在mergedFlavor上设置,更新为gradle 5.1.1

时间:2019-06-24 18:28:54

标签: android groovy build android-gradle

我已经从3.1.1更新到Gradle发行版5.1.1,它涉及许多更改,包括更新androidX支持库。由于某种原因,构建会继续失败,要求更改合并风味中的versionName设置方式。我无法弄清楚我到底缺少什么,已经添加了gradle构建结果建议的代码。

Build.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

1 个答案:

答案 0 :(得分:0)

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