我试图将Onesignal作为推送服务添加到应用程序,但是现在在编辑build.gradle文件后出现以下错误。
错误:无法获取类型为org.gradle.api.Project的根项目'android'的未知属性'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')
}
答案 0 :(得分:3)
错误Could not get unknown property 'android' for root project 'projectName' of type org.gradle.api.Project.
表示您将{em> onesignal-gradle-plugin 应用到您的root build.gradle
或android/build.gradle
而不是app/build.gradle
中的一个。移动此位置将纠正您的错误。
上下文中的行
应用插件:“ com.onesignal.androidsdk.onesignal-gradle-plugin”