In this video it shows the steps to add packagingOptions block in the gradle file in Android Studio. On adding the packagingOptions block it gives the deprecated unit error. This can be fixed by using packaging block instead of packagingOptions block.
Also, use resources.excludes.add instead of exclude option.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete details:
plugins {
id("com.android.application")
}
android {
namespace = "com.programmerworld.paclagingoptionsdeprecatedexample"
compileSdk = 34
defaultConfig {
applicationId = "com.programmerworld.paclagingoptionsdeprecatedexample"
minSdk = 34
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
packaging{
resources.excludes.add("META-INF/NOTICE.md")
resources.excludes.add("META-INF/LICENSE.md")
}
}
dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("com.sun.mail:android-mail:1.6.6")
implementation("com.sun.mail:android-activation:1.6.7")
}
Screenshots:
2 files found with path ‘META-INF/NOTICE.md’.
Adding a packagingOptions block may help, please refer to
https://developer.android.com/reference/tools/gradle-api/8.1/com/android/build/api/dsl/ResourcesPackagingOptions
for more information
packagingOptions(Packaging.() -> Unit): Unit’ is deprecated. Renamed to packaging
packaging{
resources.excludes.add(“META-INF/NOTICE.md”)
resources.excludes.add(“META-INF/LICENSE.md”)
}