Город МОСКОВСКИЙ
00:04:27

Fix "packagingOptions Unit' is deprecated. Renamed to packaging" error in Android Studio Gradle fil

Аватар
Android Explorers Guide
Просмотры:
27
Дата загрузки:
17.10.2024 08:01
Длительность:
00:04:27
Категория:
Обучение

Описание

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/ steps of this video are posted in the below link:
https://programmerworld.co/android/fix-packagingoptionspackaging-unit-unit-is-deprecated-renamed-to-packaging-error-in-android-studio-gradle-file/

However, the main code is copied below also for reference:

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")

}

--

Рекомендуемые видео