【问题标题】:Could not get unknown property 'android' for root project 'android' of type org.gradle.api.Project无法为 org.gradle.api.Project 类型的根项目“android”获取未知属性“android”
【发布时间】:2019-08-10 03:57:58
【问题描述】:

我尝试将 Onesignal 作为推送服务添加到应用程序,但现在在编辑 build.gradle 文件后出现以下错误。

错误:无法为 org.gradle.api.Project 类型的根项目“android”获取未知属性“android”。

谁能告诉我如何解决这个问题?这是我第一次编辑安卓项目。

这是我的 build.gradle(app) 文件:

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

}

【问题讨论】:

    标签: android android-studio build.gradle


    【解决方案1】:

    Could not get unknown property 'android' for root project 'projectName' of type org.gradle.api.Project. 错误意味着您将 onesignal-gradle-plugin 应用于您的 root build.gradleandroid/build.gradle,而不是 app/build.gradle 中的那个。移动这将解决您的错误。

    上下文中的行

    应用插件:'com.onesignal.androidsdk.onesignal-gradle-plugin'

    See discussion

    【讨论】:

    • 好的,这有点令人困惑,但现在我做对了,谢谢
    猜你喜欢
    • 1970-01-01
    • 2023-01-25
    • 2017-03-18
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-12
    相关资源
    最近更新 更多