gradle 正在尝试使用“com.onesignal:OneSignal:3.7.1”,但出现错误

5uzkadbs  于 2022-11-14  发布在  其他
关注(0)|答案(5)|浏览(202)

我已经打开了一个已经创建的项目。我正在添加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'

构建.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'这行项目正常运行,我没有得到一个错误。我该怎么办?需要帮助。

wribegjk

wribegjk1#

您需要在 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'
xxe27gdn

xxe27gdn2#

此版本的.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只对其中一个起作用而对另一个不起作用?

dxpyg8gm

dxpyg8gm3#

将此代码包含在您的App/build.gradle中

implementation 'com.onesignal:OneSignal:3.9.1'
knsnq2tg

knsnq2tg4#

classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'

我已经通过添加这个类路径依赖解决了这个问题,以后再更改它

elcex8rz

elcex8rz5#

1.只需转到您的build.gradle(安卓/应用程序)。
1.并删除'
应用插件:'com.onesignal. android软件包.onesignal-gradle插件'
1.然后重新运行项目,错误就会得到解决'

相关问题