# android_dependencies **Repository Path**: devlzh/android_dependencies ## Basic Information - **Project Name**: android_dependencies - **Description**: Android 常用依赖库版本管理 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-18 - **Last Updated**: 2021-03-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Android 常用依赖库版本管理 ## 配置文件 点击查看配置文件内容:[config.gradle](./config.gradle) ## 引入配置文件 在 `project/build.gradle` 中添加如下语句: ```groovy // config_url 是 config.gradle 存放地址 apply from : 'config_url' ``` ## 修改 SDK 版本号 在模块下的 `build.gradle` 文件中修改 `compileSdkVersion`, `minSdkVersion`, `targetSdkVersion` ```groovy compileSdkVersion rootProject.ext.targetSdkVersion minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion ``` ## 使用具体依赖 1. 在 [config.gradle](./config.gradle) 文件中 `depds` 中查看依赖库的名称; 2. 在模块下的 `build.gradle` 文件中添加相应的依赖; **如:** 在 `app` 模块依赖 `androidx_appcompat`, 则在 `app/build.gradle` 文件中添加如下语句: ```groovy dependencies{ implementation depds.androidx_appcompat } ``` ## 混淆配置 [retrofit2 混淆配置](https://square.github.io/retrofit/#download) ```pro # Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and # EnclosingMethod is required to use InnerClasses. -keepattributes Signature, InnerClasses, EnclosingMethod # Retrofit does reflection on method and parameter annotations. -keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations # Retain service method parameters when optimizing. -keepclassmembers,allowshrinking,allowobfuscation interface * { @retrofit2.http.* ; } # Ignore annotation used for build tooling. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement # Ignore JSR 305 annotations for embedding nullability information. -dontwarn javax.annotation.** # Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. -dontwarn kotlin.Unit # Top-level functions that can only be used by Kotlin. -dontwarn retrofit2.KotlinExtensions -dontwarn retrofit2.KotlinExtensions$* # With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy # and replaces all potential values with null. Explicitly keeping the interfaces prevents this. -if interface * { @retrofit2.http.* ; } -keep,allowobfuscation interface <1> ``` [okhttp3 混淆配置](https://square.github.io/okhttp/r8_proguard/) ```pro # JSR 305 annotations are for embedding nullability information. -dontwarn javax.annotation.** # A resource is loaded with a relative path so the package of this class must be preserved. -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. -dontwarn org.codehaus.mojo.animal_sniffer.* # OkHttp platform used only on JVM and when Conscrypt dependency is available. -dontwarn okhttp3.internal.platform.ConscryptPlatform -dontwarn org.conscrypt.ConscryptHostnameVerifier ``` [okio 混淆配置](https://square.github.io/okio/#r8-proguard) ```pro # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. -dontwarn org.codehaus.mojo.animal_sniffer.* ```