错误:清单合并失败并出现多个错误,请参阅日志

Posted

技术标签:

【中文标题】错误:清单合并失败并出现多个错误,请参阅日志【英文标题】:Error: Manifest merger failed with multiple errors, see logs 【发布时间】:2017-04-17 14:12:50 【问题描述】:

尝试在我的 android 项目上安装 OneSignal 的 SDK 后,我注意到编译时一直发生错误,这使我无法开始使用此服务。

我的 build.grade(Module:app) 文件:

    apply plugin: 'com.android.application'

android 
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig 
        applicationId "com.sourcey.project"
        minSdkVersion 17
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    
    buildTypes 
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    


repositories 
    // maven central repository
    mavenCentral()

    maven  url "https://oss.sonatype.org/content/repositories/snapshots" 



dependencies 
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
    compile 'com.microsoft.azure.android:azure-storage-android:0.6.0@aar'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.afollestad.material-dialogs:core:0.9.1.0'
    compile 'com.afollestad.material-dialogs:commons:0.9.1.0'

    **compile 'com.onesignal:OneSignal:3.+@aar'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-analytics:10.0.1'**
//Without including these 4 rows, the project building process goes perfectly.


    testCompile 'junit:junit:4.12'



apply plugin: 'com.google.gms.google-services'

感谢你们的帮助!

【问题讨论】:

LogCat 或控制台会显示哪些错误? 【参考方案1】:

在你的依赖部分你有这个:

   **compile 'com.onesignal:OneSignal:3.+@aar'

这将在您对项目进行同步时导致问题。

dependencies 
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
    compile 'com.microsoft.azure.android:azure-storage-android:0.6.0@aar'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.afollestad.material-dialogs:core:0.9.1.0'
    compile 'com.afollestad.material-dialogs:commons:0.9.1.0'

    **compile 'com.onesignal:OneSignal:3.+@aar'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-analytics:10.0.1'**
//Without including these 4 rows, the project building process goes perfectly.


    testCompile 'junit:junit:4.12'

【讨论】:

添加了星号以标记有问题的块。删除此特定行不会安装 OneSignal 的 SDK,这就是添加这 4 行的全部目的。【参考方案2】:

修复: 忘记加了-

  manifestPlaceholders = [onesignal_app_id: "PUT YOUR ONESIGNAL APP ID HERE",
                              // Project number pulled from dashboard, local value is ignored.
                              onesignal_google_project_number: "REMOTE"]

【讨论】:

你在哪里添加这个【参考方案3】:

观察包含**的行并进行必要的更改和以下操作:

android 
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    defaultConfig 
        applicationId 'com.edesonabizerril.newintercampi'
        **manifestPlaceholders = [onesignal_app_id: "000000000-b000-4d1e-0000-00000000000000",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]**
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 13
        multiDexEnabled false
        versionName '1.10'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    
    buildTypes 
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    
    productFlavors 
    


dependencies 
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', 
        exclude group: 'com.android.support', module: 'support-annotations'
    )
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.firebase:firebase-database:12.0.1'
    ...

    **implementation 'com.onesignal:OneSignal:3.+@aar'**

    testImplementation 'junit:junit:4.12'


apply plugin: 'com.google.gms.google-services'

【讨论】:

以上是关于错误:清单合并失败并出现多个错误,请参阅日志的主要内容,如果未能解决你的问题,请参考以下文章

任务 ':app:compileDebugKotlin' 执行失败。 >内部编译器错误。有关详细信息,请参阅日志

错误:任务“:app:compileDebugKotlin”执行失败。 > 编译错误。有关详细信息,请参阅日志

在 Worklight 中构建和部署失败并出现 openjpa 致命一般错误

一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性

一例对一个或多个实体的验证失败。有关详细信息,请参阅“EntityValidationErrors”属性的解决

System.Net.WebException:错误:TrustFailure(身份验证失败,请参阅内部异常。)