I am new to java and android. And on running the emulator I am facing this merge conflict issue.
Complete Error message:
Execution failed for task ':processDefaultsDebugMainManifest'.
Manifest merger failed with multiple errors, see logs
Error: android:exported needs to be explicitly specified for element <activity#com.squareup.leakcanary.internal.DisplayLeakActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for
android:exported
when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. main manifest (this file), line 35
Here AndroidManifest.xml
<?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="com.iab.omid.sampleapp">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:networkSecurityConfig="@xml/network_security_config"
android:name=".AdApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".AdListActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".AdDetailActivity"
android:label="@string/title_ad_detail"
android:parentActivityName=".AdListActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.iab.omid.sampleapp.AdListActivity"/>
</activity>
</application>
and build.gradle
buildscript {
ext {
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
}
}
apply plugin: 'com.android.application'
repositories {
google()
maven {
url "https://plugins.gradle.org/m2/"
}
}
android {
compileSdk 32
flavorDimensions ""
defaultConfig {
applicationId "com.iab.omid.sampleapp"
minSdkVersion 18
targetSdkVersion 32
versionCode 1020
versionName "1.1.3"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
buildConfigField("String", "PARTNER_NAME", "\"com.iab.omid.sampleapp\"")
buildConfigField("String", "VENDOR_KEY", "\"dummyVendor\"")
buildConfigField("String", "VALIDATION_SCRIPT_URL", "\"complianceomsdk.iabtechlab.com\"")
// This override URL will only change URLs seen in Charles proxy for Html ads
buildConfigField("String", "VALIDATION_SCRIPT_URL_OVERRIDE", "\"complianceomsdk.iabtechlab.com\"")
buildConfigField("String", "VERIFICATION_URL", "\"https://s3-us-west-2.amazonaws.com/omsdk-files/compliance-js/omid-validation-verification-script-v1.js\"")
buildConfigField("String", "VERIFICATION_PARAMETERS", "\"http://omid-android-reference-app/sendMessage?msg=\"")
buildConfigField("String", "HTML_DISPLAY_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_display_creative.html\"")
buildConfigField("String", "HTML_VIDEO_AD", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/creatives/html_video_creative.html\"")
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
defaults {
}
instrumentationTest {
buildConfigField("String", "VERIFICATION_URL", "\"https://omsdk-files.s3-us-west-2.amazonaws.com/fullstack/fullstack-verification-script.js\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '32.0.0'
}
dependencies {
implementation fileTree(include: ['*.aar'], dir: '../')
implementation 'com.google.android.exoplayer:exoplayer:2.10.5', {
exclude group: 'com.android.support'
}
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'commons-io:commons-io:2.4'
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'org.apache.commons:commons-lang3:3.6'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation 'androidx.annotation:annotation:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'org.mockito:mockito-android:4.3.1'
androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
task downloadOMSDKJS(type:Exec) {
if (!file('./src/main/res/raw/omsdk_v1.js').exists()) {
workingDir '../'
commandLine 'sh', './scripts/download-omsdk-js.sh'
} else {
// We need a dummy execCommand here.
commandLine 'sh'
}
}
preBuild.dependsOn downloadOMSDKJS
I have already tried many other solutions available on StackOverflow but still haven't made any progress.
Please let me know if any more details are required to be shared to solve this in a comment.
CodePudding user response:
Your libraries are defining probably an "intent_filter" on an activity
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
If your application is targeting API 31 , the attribute "exported" is mandatory.
So as the developer of that library didn't target API 31, the exported flag what not mandatory on his side. And he built it without exported attribute.
So what you can do, is redefine that specific class on your manifest to declare it explicitly exported or not. For example :
<activity android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:exported="true"/>