Could not get unknown property 'android' for root project 'android' of type org.gradle.api.Project

Issue

I tried to add Onesignal as Push Service to an App, but now i get following error after editing the build.gradle file.

ERROR: Could not get unknown property ‘android’ for root project ‘android’ of type org.gradle.api.Project.

Can someone tell me how to fix that? It’s my first time editing an android project.

Thats my build.gradle(app) file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        applicationId "io.gonative.android.azndpe"
        versionCode 2

        manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                onesignal_app_id: "APP-ID",
                                onesignal_google_project_number: "REMOTE"]
    }

    signingConfigs {
        release {
            storeFile file("../../release.keystore")
            storePassword "password"
            keyAlias "release"
            keyPassword "password"
        }
        upload {
            storeFile file("../../upload.keystore")
            storePassword "password"
            keyAlias "upload"
            keyPassword "password"
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        releaseApk {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
            zipAlignEnabled true
            signingConfig signingConfigs.release
        }
        releaseAppbundle {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
            zipAlignEnabled true
            signingConfig signingConfigs.upload
        }
    }

    flavorDimensions "webview"

    productFlavors {
        normal {
            dimension "webview"
        }
    }
}

dependencies {
    implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.39.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-gcm:12.0.1'
    implementation 'com.google.android.gms:play-services-location:12.0.1'
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    implementation fileTree(dir: 'libs', include: '*.jar')
    implementation fileTree(dir: 'libs', include: '*.aar')

}

Solution

The error Could not get unknown property 'android' for root project 'projectName' of type org.gradle.api.Project. means you applied the onesignal-gradle-plugin to your root build.gradle or android/build.gradle instead of the one in app/build.gradle. Moving this will fix your error.

Line in context

apply plugin: ‘com.onesignal.androidsdk.onesignal-gradle-plugin’

See discussion

Answered By – Giddy Naya

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published