无法获得类型为org.gradle.api.Project的项目':app'的未知属性'file'

时间:2019-05-30 06:12:01

标签: android android-gradle build.gradle

我在Music Streaming应用程序的应用程序项目中始终遇到此错误:

  

无法获取类型为org.gradle.api.Project的项目':app'的未知属性'file'。

我想知道我在做什么错。无论我尝试什么,我都会陷入困境。

这是Android Studio中的App项目。

apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}

android {

    buildTypes {
        release {
            ndk {
                abiFilters "armeabi-v7a" // includes ARM SO files only, so no x86 SO file
            }
        }
    }

//    packagingOptions {
//        exclude "lib/mips"
//    }

    compileSdkVersion 28
    defaultConfig {
        applicationId "cloud.veezee.android"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 10
        versionName "1.1"
        renderscriptTargetApi 21
        renderscriptSupportModeEnabled true
        multiDexEnabled true

//        buildConfigField 'String', 'GoogleAndroidClientId', GoogleAndroidClientId
        buildConfigField 'String', 'GoogleServerClientId', GoogleServerClientId
    }
    signingConfigs {
        release {
            storeFile file("../keystore.jks")
            storePassword ANDROID_STORE_PASSWORD
            keyAlias ANDROID_STORE_ALIAS
            keyPassword ANDROID_KEY_PASSWORD
        }
        buildTypes {
            release {
//                minifyEnabled true
//                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                signingConfig signingConfigs.release
            }
            debug {
                signingConfig signingConfigs.release
            }
        }
    }

    dataBinding {
        enabled = true
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation "org.jetbrains.anko:anko-commons:0.10.7"
        implementation "com.android.support:appcompat-v7:28.0.0"
        implementation "com.android.support:support-media-compat:28.0.0"
        implementation "com.android.support:support-v4:28.0.0"
        implementation 'com.android.support:cardview-v7:28.0.0'
        implementation 'com.android.support:design:28.0.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'com.google.android.gms:play-services-auth:16.0.1'
        implementation 'me.everything:overscroll-decor-android:1.0.4'
        implementation 'com.miguelcatalan:materialsearchview:1.4.0'
        implementation 'com.google.android.exoplayer:exoplayer:2.7.0'
        implementation 'com.android.volley:volley:1.1.0' 
        implementation 'com.google.code.gson:gson:2.8.2'
        implementation 'com.sothree.slidinguppanel:library:3.4.0'
        implementation 'com.appsee:appsee-android:2.4.1'
        implementation 'com.danikula:videocache:2.7.0'
        implementation 'com.couchbase.lite:couchbase-lite-android:2.0.0'
        implementation 'com.github.bumptech.glide:glide:4.7.1'
        implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
        implementation 'com.yarolegovich:discrete-scrollview:1.4.9'
        implementation 'jp.wasabeef:glide-transformations:3.3.0'
        kapt 'com.github.bumptech.glide:compiler:4.7.1'

        implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
            transitive = true
        }
    }
}

afterEvaluate {
    initFabricPropertiesIfNeeded()
}

def initFabricPropertiesIfNeeded() {
    def propertiesFile = file
    if (!propertiesFile.exists()) {
        ant.propertyfile(file: "fabric.properties", comment: commentMessage) {
            entry(key: "apiSecret", value: FabricSecretKey)
            entry(key: "apiKey", value: FabricApiKey)
        }
    }
}

1 个答案:

答案 0 :(得分:0)

  

App:无法获得类型为org.gradle.api.Project的项目':app'的未知属性'file'。

问题出在这一行:

def initFabricPropertiesIfNeeded() {
    def propertiesFile = file
    //....
}

您可以检查official doc

  

Project.file(java.lang.Object)方法用于创建相对于当前项目的文件或目录路径,并且是使构建脚本不管项目路径如何都可以工作的常用方法。

您必须使用以下方式更改脚本:

def propertiesFile = file('myFile.properties')

(也许是,但我不确定def propertiesFile = file('fabric.properties')