【问题标题】:cannot upgrade to gradle 5 - got "The project name '../../' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]."无法升级到 gradle 5 - 得到“项目名称 '../../' 不得包含以下任何字符:[/、\​​、:、<、>、”、?、*、|]。”
【发布时间】:2019-11-12 12:32:38
【问题描述】:

我正在尝试升级到 gradle 5.1.1 并收到错误消息: 项目名称'../../'不得包含以下任何字符:[/、\​​、:、、"、?、*、|]。设置'rootProject.name'或调整'include' 语句。

我在项目名称中找不到任何禁止的内容。 该项目是一个 SDK。

gradle 版本是:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

应用 gradle 是:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'           
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "http://art01.corp.tity.com:8081/tory/inhouse/"
        }

        maven {
            url "http://art01.corp.tity.com:8081/tory/repo"
        }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
    }
}

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

模型gradle文件为:

import java.util.regex.Matcher
import java.util.regex.Pattern

apply plugin: 'com.android.library'
apply plugin: 'maven'

println GradleVersion.current().getVersion() + " - " + GradleVersion.current().getBuildTime() + " - " + GradleVersion.current().getRevision() + GradleVersion.current().isSnapshot() ? " - is snapshot" : ""


def isDebugBuild=0;
gradle.startParameter.taskNames.each {
    taskName -> println "taskName=" + taskName
    if (taskName.contains("Debug")){
        isDebugBuild=1
    }
}

def currentFlavor = ""
def appVersionCode = getVersionCode();
def coreAarFile
def mapFile = ""

android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'

    def WEB_APP_NAME = "id"
    println "project.name()=" + project.getName()

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 27
        versionCode appVersionCode
        versionName "1.4"

        buildConfigField "String", "URL_ACCESS_NAME", "\"" + WEB_APP_NAME + "\""
    }

    def VAR_ENVIRONMENT = "ENVIRONMENT"

    buildTypes {
        debug {
            buildConfigField "ch.qos.logback.classic.Level", "LOG_LEVEL", 'ch.qos.logback.classic.Level.DEBUG'
            signingConfig signingConfigs.debug
            minifyEnabled false
        }
    }

    flavorDimensions "version"
    productFlavors {
        envTest {
            dimension "version"
            buildConfigField "String", VAR_URL_ACCESS_IP_US, '"' + TEST_SERVER_IP_US + '"'
            manifestPlaceholders = [serverIpUS: TEST_SERVER_IP_US, serverIpEU: TEST_SERVER_IP_EU, serverIpAU: TEST_SERVER_IP_AU, servletName: WEB_APP_NAME]
        }
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }
    }
    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/*'
        exclude 'META-INF/maven'
    }

    testOptions {
        unitTests.returnDefaultValues = true

    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {

     //LOGGING FACADE AND IMPLEMENTATION
    implementation 'org.slf4j:slf4j-api:1.7.26'
    implementation 'com.github.tony19:logback-android-core:1.1.1-6'
    implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
        exclude group: 'com.google.android', module: 'android'
    }

    implementation 'org.bitbucket.b_c:jose4j:0.6.5'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'commons-codec:commons-codec:1.12'
    implementation 'com.madgag.spongycastle:prov:1.58.0.0'

    implementation 'com.google.android.gms:play-services-base:16.0.1'
    implementation 'com.google.android.gms:play-services-safetynet:16.0.0'

    implementation 'com.google.firebase:firebase-messaging:18.0.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'junit:junit:4.12'
}

def getVersionCode()
{
    def Properties versionProps = new Properties()
    def versionPropsFile = file('version.properties')
    if (versionPropsFile.exists() && versionPropsFile.canRead()) {
        versionProps.load(new FileInputStream(versionPropsFile))
    } else {
        throw new GradleException("Could not read version.properties!")
    }
    def code = (versionProps['VERSION_CODE'] ?: "0").toInteger()
    return code
}

task('incrementVersionCode') << {
    def Properties versionProps = new Properties()
    def versionPropsFile = file('version.properties')
    if (versionPropsFile.exists() && versionPropsFile.canRead()) {
        versionProps.load(new FileInputStream(versionPropsFile))
    } else {
        throw new GradleException("Could not read version.properties!")
    }
    def code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1
    versionProps['VERSION_CODE'] = code.toString()
    versionProps.store(versionPropsFile.newWriter(), null)
    return code
}

currentFlavor = getCurrentFlavor()
println "currentFlavor=" + currentFlavor

def filePrefix=""
def fileFlavor=""
def fileBuildType=""
def mappingFilePath=""

filePrefix="$buildDir/outputs/aar/idsdkclient-"

if (currentFlavor.equals("EnvTest")){
    fileFlavor="envTest"
}

if (isDebugBuild==1){
    fileBuildType="debug"
}

println "aar file = " + filePrefix + fileFlavor + "-" + fileBuildType + ".aar"
coreAarFile = file(filePrefix + fileFlavor + "-" + fileBuildType + ".aar")

println "build file=" + coreAarFile.absolutePath + ", exists=" + coreAarFile.exists()

println 'Artifacts:'
configurations.findAll().each { config ->
    config.allArtifacts.getFiles().each { file ->  println "Artifact : ${config}: " + file }
}

artifacts {
    archives coreAarFile
    if (mappingFilePath.length()>0){
        archives mappingFile
    }
}

uploadArchives{
    repositories {
        mavenDeployer {
            repository(url: TITY_MAVEN_REPO_INHOUSE_URL) {
                    if (maven_user != null && maven_password != null) {
                    authentication(userName: maven_user, password: maven_password)
                } else {
                    authentication(userName: mavenUser, password: mavenPassword)
                }
            }

            pom.groupId = 'com.tity.id.sdk'
            pom.artifactId = "idsdkclient-" + fileFlavor + "-" + fileBuildType
            println "pom.artifactId=" + pom.artifactId + ", android.defaultConfig.versionName = " + android.defaultConfig.versionName + ", android.defaultConfig.versionCode=" + android.defaultConfig.versionCode
            pom.version = android.defaultConfig.versionName + '-b' + android.defaultConfig.versionCode
            pom.packaging = 'aar'
        }
    }
}

def getCurrentFlavor() {
    Gradle gradle = getGradle()
    String  tskReqStr = gradle.getStartParameter().getTaskRequests().toString()

    Pattern pattern;

    if( tskReqStr.contains( "assemble" ) )
        pattern = Pattern.compile("assemble(\\w+)(Release|Debug)")
    else
        pattern = Pattern.compile("generate(\\w+)(Release|Debug)")

    Matcher matcher = pattern.matcher( tskReqStr )

    if( matcher.find() )
        return matcher.group(1)
    else
    {
        return "";
    }
}

你能建议吗?

【问题讨论】:

    标签: android gradle sdk build.gradle


    【解决方案1】:

    卖掉了。 问题出在文件“settngs.gradle”中。 有一行:

    include ':idsdkclient',
    

    应该是:

    include 'idsdkclient'
    

    模型模型的另一个问题:

    task('incrementVersionCode') << {
      ..
    }
    

    应该是:

    task myTask {
        doLast {
    ..
    }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-06-28
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 2013-08-31
      • 1970-01-01
      • 2017-07-24
      相关资源
      最近更新 更多