ARouter使用随记
其他配置
1.创建一个config.gradle
ext{ isDebug = false //false:作为Lib集成存在, true:作为application组件存在 android = [ compileSdkVersion : 28, minSdkVersion :19, targetSdkVersion :27, versionCode :1, versionName :"1.0", ] libsVersion=[ // App dependencies version supportVersion = "28.0.0", glideVersion = "4.7.1", retrofitVersion ="2.5.0", okhttpVersion = "3.8.0", ] dependencies = [ //android 官方库 "appcompat-v7" : "com.android.support:appcompat-v7:$rootProject.supportVersion", "support-v4" : "com.android.support:support-v4:$rootProject.supportVersion", "design" : "com.android.support:design:$rootProject.supportVersion", "annotations" : "com.android.support:support-annotations:$rootProject.supportVersion", "gson" : "com.google.code.gson:gson:2.6.2", //路由通讯 "arouter-api" : "com.alibaba:arouter-api:1.4.1", "arouter-compiler" : "com.alibaba:arouter-compiler:1.2.2", ] }
Project gradle引用
apply from:"config.gradle"
2.module gradle配置
def isDebug = rootProject.ext.isDebug def configs = rootProject.ext.android def librarys = rootProject.ext.dependencies if(isDebug){ apply plugin: 'com.android.application' }else { apply plugin: 'com.android.library' } android { compileSdkVersion configs.compileSdkVersion defaultConfig { minSdkVersion configs.minSdkVersion targetSdkVersion configs.targetSdkVersion versionCode configs.versionCode versionName configs.versionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" if (isDebug) { applicationId "xx.xx.xx" } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } sourceSets { main { //控制两种模式下的资源和代码配置情况 if (isDebug) { manifest.srcFile 'src/main/debug/AndroidManifest.xml' } else { manifest.srcFile 'src/main/AndroidManifest.xml' //集成开发模式下排除debug文件夹中的所有Java文件 java { exclude 'debug/**' } } } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } }
debug下的
作为lib时的
解决错误:InstantRun support error, com.android.tools.fd.runtime.Paths 以及 There is no route match the path
每个需要路由操作的module 都需要添加
implementation 'com.alibaba:arouter-api:x.x.x' annotationProcessor 'com.alibaba:arouter-compiler:x.x.x'
app gradle配置(将需要路由操作的module都依赖到app的module下)
dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' //noinspection GradleCompatible androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation project(':基类module') if (!isDebug){ implementation project(':login') implementation project(':test') } }
本文来自博客园,作者:西瓜皮不甜,转载请注明原文链接:https://www.cnblogs.com/Jieth/p/10470023.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· PowerShell开发游戏 · 打蜜蜂
· 凌晨三点救火实录:Java内存泄漏的七个神坑,你至少踩过三个!