我是java和android的新手。在運行模擬器時,我面臨著這個合并沖突問題。
完整的錯誤資訊:
任務“:processDefaultsDebugMainManifest”執行失敗。
清單合并失敗并出現多個錯誤,請參閱日志
錯誤:需要為元素 <activity#com.squareup.leakcanary.internal.DisplayLeakActivity> 顯式指定 android:exported。面向 Android 12 及更高版本的應用需要為
android:exported
相應組件定義了 Intent 過濾器時指定顯式值。有關詳細資訊,請參閱https://developer.android.com/guide/topics/manifest/activity-element#exported。主清單(此檔案),第 35 行
這里 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>
和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
我已經在 StackOverflow 上嘗試了許多其他可用的解決方案,但仍然沒有取得任何進展。
請讓我知道是否需要在評論中共享更多詳細資訊以解決此問題。
uj5u.com熱心網友回復:
您的庫可能正在為活動定義“intent_filter”
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
如果您的應用程式面向 API 31 ,則“exported”屬性是強制性的。
因此,由于該庫的開發人員沒有針對 API 31,因此匯出的標志對他來說不是強制性的。他在沒有匯出屬性的情況下構建了它。
因此,您可以做的是重新定義清單上的特定類,以宣告它是否顯式匯出。例如 :
<activity android:name="com.squareup.leakcanary.internal.DisplayLeakActivity"
android:exported="true"/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/454459.html
標籤:爪哇 安卓 安卓工作室 构建.gradle 机器人清单