Admobを com.google.android.gms:play-services-ads:20.4.0 に対応したところ、それまで問題なかったJavaMailがエラーを吐いてクラッシュするようになってしまいました。
Admob導入時の変更内容は、下記に示すとおりで、compileSdkはadmob導入の結果、要求されたため31に上げました。(mailの部分は、もともとのJavaMailのために記述している部分で変更はしていません。)
android {
compileSdk 31
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:20.4.0'
// For apps targeting Android 12, add WorkManager dependency.
constraints {
implementation('androidx.work:work-runtime:2.7.0') {
because '''androidx.work:work-runtime:2.1.0 pulled from play-services-ads
has a bug using PendingIntent without FLAG_IMMUTABLE or
FLAG_MUTABLE and will fail in apps targeting S+.'''
}
}
implementation 'com.sun.mail:android-mail:1.6.5'
implementation 'com.sun.mail:android-activation:1.6.5'
}
調べたところ、compileSdkを29に下げるとおさまる、といった内容がみつかりましたが、下げるとadmobも下げなければならないため、探したところ、次のようにして解決しました。
android {
compileSdk 31
packagingOptions {
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:20.4.0'
// For apps targeting Android 12, add WorkManager dependency.
constraints {
implementation('androidx.work:work-runtime:2.7.0') {
because '''androidx.work:work-runtime:2.1.0 pulled from play-services-ads
has a bug using PendingIntent without FLAG_IMMUTABLE or
FLAG_MUTABLE and will fail in apps targeting S+.'''
}
}
implementation 'com.sun.mail:android-mail:1.6.6'
implementation 'com.sun.mail:android-activation:1.6.6'
}
packagingOptionsの部分を追加し、mail関連の部分のバージョンを1.6.6に上げることでエラーが出なくなりました。
comment