[英]Manifest merger failed with multiple errors, see logs android studio
[英]Android 12 Manifest merger failed with multiple errors, see logs
正如标题所说,我最近遇到了 targetSDK 31 的问题。当我使用 targetSDK 30 或更低版本时,我从来没有遇到过问题。 我尝试了许多在网上找到的解决方案,但都没有运气。 以下是我项目的一些文件。
我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="warp.ly.demo">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.SEND" />
<!-- Restrict Tablets -->
<!-- <supports-screens-->
<!-- android:largeScreens="true"-->
<!-- android:normalScreens="true"-->
<!-- android:smallScreens="true"-->
<!-- android:xlargeScreens="false" />-->
<!-- tools:node="replace"-->
<application
android:name="warp.ly.demo.WarplyDemoApplication"
android:allowBackup="false"
android:exported="false"
android:extractNativeLibs="true"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_notification_logo"
android:installLocation="internalOnly"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme">
<!-- For Huawei Push -->
<meta-data
android:name="push_kit_auto_init_enabled"
android:value="true" />
<meta-data
android:name="com.huawei.hms.client.channel.androidMarket"
android:value="false" />
<activity
android:name="warp.ly.demo.activities.SplashActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.MainActivity"
android:label="@string/title_activity_main"
android:screenOrientation="portrait" />
<activity
android:name=".activities.InboxActivity"
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.activities.WarpViewActivity"
android:label=""
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.dexter.PermissionsActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Light.NoTitleBar" />
<!-- Service used for updating user's location. -->
<service
android:name="ly.warp.sdk.services.UpdateUserLocationService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name="ly.warp.sdk.services.WarplyBeaconsRangingService"
android:exported="false" />
<!-- Service used for in app notification. -->
<service
android:name="ly.warp.sdk.services.WarpInAppNotificationService"
android:exported="false" />
<!-- Service used for handling Huawei Push Notifications, comment if we are in Google build -->
<service
android:name="ly.warp.sdk.services.HMSBaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- FCM Service for push notifications -->
<service
android:name="ly.warp.sdk.services.FCMBaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<receiver
android:name="ly.warp.sdk.receivers.LocationChangedReceiver"
android:exported="false" />
<receiver
android:name="ly.warp.sdk.receivers.ConnectivityChangedReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<category android:name="warp.ly.demo" />
</intent-filter>
</receiver>
<receiver
android:name="ly.warp.sdk.receivers.BluetoothStateChangeReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name="ly.warp.sdk.receivers.WarplyInAppNotificationReceiver"
android:exported="false" />
</application>
<!-- For Huawei Push, only if we targetSdkVersion 30, comment if we are in Google build -->
<!-- <queries>-->
<!-- <intent>-->
<!-- <action android:name="com.huawei.hms.core.aidlservice" />-->
<!-- </intent>-->
<!-- </queries>-->
</manifest>
我的应用程序-> build.gradle 文件
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.huawei.agconnect'
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "warp.ly.demo"
minSdkVersion 23
targetSdkVersion 31
versionCode 100
versionName "1.0.0"
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
config {
// Set the parameters based on the actual signing information.
keyAlias 'warplydemo'
keyPassword 'warplydemo'
storeFile file('../keystore/warplydemo.jks')
storePassword 'warplydemo'
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
}
release {
signingConfig signingConfigs.config
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libraries:warply_android_sdk')
//Support
implementation 'androidx.appcompat:appcompat:1.4.0' //1.4.0 if targetSDK is 31 else 1.3.1
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'org.altbeacon:android-beacon-library:2.19.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
// Huawei SDK
implementation 'com.huawei.agconnect:agconnect-core:1.6.2.300'
}
我图书馆的应用程序-> build.gradle 文件
apply plugin: 'com.android.library'
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
minSdkVersion 23
targetSdkVersion 31
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
//------------------------------ Support -----------------------------//
implementation 'androidx.appcompat:appcompat:1.4.0' //1.4.0 if targetSDK is 31 else 1.3.1
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'org.altbeacon:android-beacon-library:2.19.3'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation "commons-logging:commons-logging:1.2"
//------------------------------ Firebase -----------------------------//
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation 'com.google.firebase:firebase-messaging'
//------------------------------ GMS -----------------------------//
implementation 'com.google.android.gms:play-services-base:18.0.1'
//------------------------------ Work Manager -----------------------------//
implementation 'androidx.work:work-runtime:2.7.1' //2.7.1 if targetSDK is 31 else 2.6.0
//------------------------------ Glide -----------------------------//
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
//------------------------------ Huawei -----------------------------//
implementation 'com.huawei.hms:push:5.1.1.301'
implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
//------------------------------ SQLCipher -----------------------------//
implementation 'net.zetetic:android-database-sqlcipher:4.4.3@aar'
implementation "androidx.sqlite:sqlite:2.2.0" //2.2.0 if targetSDK is 31 else 2.0.1
}
// In every export please update the version number
task deleteJarLibrary(type: Delete) {
delete 'jar/warply_android_sdk_v4.5.0.jar'
}
//from('build/intermediates/compile_library_classes/release/')
//Old version
// Gradle Tasks -> warply_android_sdk -> Tasks -> other -> createJarLibrary
//task createJarLibrary(type: Copy) {
// from fileTree('build/intermediates/bundles/release/')
// into('jar/')
// include('classes.jar')
// rename('classes.jar', 'warply_android_sdk_v4.4.2.jar')
//}
// New version
// Gradle Tasks -> warply_android_sdk -> Tasks -> other -> createFullJarRelease
// When finished it copies tha .jar into
// warply_android_sdk -> build -> intermediates -> full_jar -> release -> createFullJarRelease
task createJarLibrary(type: Jar, dependsOn: 'assembleRelease') {
from fileTree('build/intermediates/bundles/release/')
}
createJarLibrary.dependsOn(deleteJarLibrary, build)
我的合并清单
我已经尝试了在这里或谷歌中找到的所有解决方案。 提前致谢!
我给你缝了 5 个活动,只有第一个活动具有以下属性。
android:exported="true"
只需尝试将此属性添加到清单中活动的 rest 即可。
<activity
android:name=".activities.MainActivity"
android:label="@string/title_activity_main"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name=".activities.InboxActivity"
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.activities.WarpViewActivity"
android:label=""
android:exported="true"
android:screenOrientation="portrait" />
<activity
android:name="ly.warp.sdk.dexter.PermissionsActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:exported="true"
android:theme="@android:style/Theme.Light.NoTitleBar" />
经过这么多小时的反复试验,我找到了问题的根源。 华为推送套件库中的一些接收器没有导出属性。 我将它更新到最新版本,我的项目构建得很好。
最新版本的华为 PushKit
implementation 'com.huawei.hms:push:6.1.0.300'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.