path和baseDir都不能为null或空字符串

时间:2017-01-14 05:03:18

标签: java android gradle

我导入了一个开源项目,当它同步项目时,我遇到了以下问题,并且无法弄清楚如何解决问题。

  

错误:(99,0)path和baseDir都不是null或空字符串。   路径='空' BASEDIR =' /用户/ Technologx /桌面/ 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'
}

1 个答案:

答案 0 :(得分: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