我打开了一个已经创建的项目。我正在添加Firebase和onesignal。已经添加了firebase,但是当我尝试添加此行时出现错误:
implementation 'com.onesignal:OneSignal:3.7.1'
错误是:AAPT2 error: check logs for details
图像可能无法显示,对此感到抱歉。
build.gradle(模块:应用):
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "dedeler.com.deredere"
minSdkVersion 17
targetSdkVersion 24
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '82f1gtd7-uy16-4c37-80s4-b1ebd8ad38a6',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '837758431119'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/ftp4j-1.7.2.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.code-troopers.betterpickers:library:3.0.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:16.0.1'
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.7.1'
}
apply plugin: 'com.google.gms.google-services'
build.gradle(项目):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我删除implementation 'com.onesignal:OneSignal:3.7.1'
这个正常运行的项目时,我没有收到错误。我该怎么办?需要帮助。
答案 0 :(得分:1)
您需要在{em> build.gradle 中为其添加plugin
,如下所示。
buildscript {
repositories {
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:4.0.0'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.11.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在应用级别 build.gradle 中添加此内容。
在顶部应用插件。
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
内部依赖项。
implementation 'com.onesignal:OneSignal:3.9.1'
答案 1 :(得分:1)
此build.gradle不适用于Onesignal(并且没有错误)
apply plugin: 'com.android.application'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
android {
compileSdkVersion 24
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "dedeler.com.dedede"
minSdkVersion 17
targetSdkVersion 24
versionCode 11
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '18u4a466-37t1-4f9n-bacd-cac2ed8f9c3c',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '357658431414'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/ftp4j-1.7.2.jar')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.code-troopers.betterpickers:library:3.0.1'
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
compile 'me.dm7.barcodescanner:zbar:1.9'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.google.firebase:firebase-messaging:17.1.0'
compile 'com.squareup.okhttp3:okhttp:3.7.0'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.onesignal:OneSignal:3.+@aar'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
}
apply plugin: 'com.google.gms.google-services'
此build.gradle与通常在Onesignal上正常运行有关:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.berkancalikoglu.onesignalpushdemotutorial"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [
onesignal_app_id : '9a39e119-d312-4517-a145-ea00482fa037',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: '260945562180'
]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.onesignal:OneSignal:3.9.2'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-location:12.0.1'
}
apply plugin: 'com.google.gms.google-services'
为什么Onesignal不能一个工作?
答案 2 :(得分:0)
将此代码包含在您的App / build.gradle
中implementation 'com.onesignal:OneSignal:3.9.1'
答案 3 :(得分:0)
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
我已经解决了此类路径依赖项的问题,后来又对其进行了更改