【问题标题】:Neither path nor baseDir may be null or empty stringpath 和 baseDir 都不能为 null 或空字符串
【发布时间】:2017-01-14 05:03:17
【问题描述】:

我导入了一个开源项目,当它同步项目时,我遇到了以下问题,不知道如何解决这个问题。

Error:(99, 0) path 和 baseDir 都不能为 null 或空字符串。 path='null' basedir='/Users/Technologx/Desktop/Android 项目/新建/sysexplorer'

这是我的 build.gradle 代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.1'

    defaultConfig {
        versionName "1.0"
        versionCode = 10
        minSdkVersion 17
        targetSdkVersion 25
        vectorDrawables.useSupportLibrary = true
    }
    signingConfigs {
        release
    }
    buildTypes {
        debug {
            minifyEnabled false
            shrinkResources true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard/proguard-project.pro',
                    'proguard/proguard-google-play-services.pro'
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard/proguard-project.pro',
                    'proguard/proguard-google-play-services.pro'
        }
    }
    flavorDimensions "release", "default"
    productFlavors {
        free {
            applicationId "com.technologx.sysexplorer.free"
            dimension "default"
        }
        pro {
            applicationId "com.technologx.sysexplorer.pro"
            dimension "default"
        }
        underground {
            applicationId "com.technologx.sysexplorer.underground"
            dimension "default"
        }
        google {
            dimension "release"
        }
        amazon {
            dimension "release"
        }
        other {
            dimension "release"
        }
    }
    variantFilter { variant ->
        def names = variant.flavors*.name

        if (names.contains("underground") && (names.contains("google") || names.contains("other"))) {
            variant.ignore = true
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
    }
    lintOptions {
        abortOnError false
    }
    aaptOptions {
        noCompress 'apk'
    }
}

ext {
    supportLibVersion = '25.1.0'
    gmsVersion = '10.0.1'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.jaredrummler:android-processes:+'
    compile 'com.github.mjdev:libaums:+'
    compile 'org.apache.ftpserver:ftpserver-core:+'
    compile 'commons-net:commons-net:+'
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:exifinterface:${supportLibVersion}"
    freeCompile "com.google.firebase:firebase-crash:${gmsVersion}"
    freeCompile "com.google.firebase:firebase-ads:${gmsVersion}"
}

def props = new Properties()
props.load(new FileInputStream(rootProject.file("keystore.properties")))
android.signingConfigs.release.storeFile rootProject.file(props.keyStore)
android.signingConfigs.release.storePassword props.keyStorePassword
android.signingConfigs.release.keyAlias props.keyAlias
android.signingConfigs.release.keyPassword props.keyAliasPassword

if (getGradle().getStartParameter().getTaskRequests().toString().contains("Free")) {
    apply plugin: 'com.google.gms.google-services'
}

【问题讨论】:

    标签: java android gradle


    【解决方案1】:

    我猜问题出在这一行:

    android.signingConfigs.release.storeFile rootProject.file(props.keyStore)
    

    Gradle 告诉您可能的 null 或空字符串被传递给 file() 方法(props.keyStore 变量)。您需要在build.gradle 中明确定义和初始化它。或者你需要有 keystore.properties 文件(在项目根目录中),内容如下:

    keyStore=your_keystore_file
    keyStorePassword=your_store_pass
    keyAlias=your_alias
    keyAliasPassword=your_alias_pass
    

    【讨论】:

      猜你喜欢
      • 2017-03-15
      • 2012-06-12
      • 2012-07-19
      • 1970-01-01
      • 2014-12-18
      • 2018-02-17
      • 1970-01-01
      • 2022-11-12
      • 1970-01-01
      相关资源
      最近更新 更多