Zafir Hussain
Zafir Hussain

Reputation: 51

Could not get unknown property 'file' for project ':app' of type org.gradle.api.Project

I keep getting this error in the app project on my Music Streaming App:

Could not get unknown property 'file' for project ':app' of type org.gradle.api.Project.

I would like to know what i am doing wrong. I keep getting stuck no matter what i try.

Here is the App Project from Android Studio.

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)
        }
    }
}

Upvotes: 3

Views: 21097

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363587

App: Could not get unknown property 'file' for project ':app' of type org.gradle.api.Project.

The issue is in this line:

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

You can check the official doc.

The Project.file(java.lang.Object) method is used to create a file or directory path relative to the current project and is a common way to make build scripts work regardless of the project path.

You have to change your script in something like:

def propertiesFile = file('myFile.properties')

(may be but I can't be sure def propertiesFile = file('fabric.properties'))

Upvotes: 3

Related Questions