当前位置:网站首页>Android studio import customized framework classess.jar As 4.0.1 version is valid for pro test
Android studio import customized framework classess.jar As 4.0.1 version is valid for pro test
2020-11-09 12:12:00 【osc_ydeb2o99】
occasionally , We need to call the system framework Layer hidden interface , Or some customized interfaces , So in androidstudio Without special configuration and processing , The default preference is android sdk api. Then we need to make the following configuration :
step 1: stay Moudle Under the app Add below libs Folder , And put your own jar The bag is in it .
--app
--libs
---framework.jar
step 2: stay Moudle Under the app In the catalog build.gradle Add the following red code to the file .
dependencies {
compileOnly files('libs/framework.jar')
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
preBuild {
doLast {
def imlFile = file(project.name + ".iml")
println 'Change ' + project.name + '.iml order'
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (FileNotFoundException e) {
// nop, iml not found
}
}
}
In fact, the above one preBuild{...} The main thing is to default to android sdk Put it at the back , This is your own framework.jar You can give priority to .
step 3: stay project In the root directory build.gradle Add the following code under the file :
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:app\\libs\\framework.jar')
}
}
repositories {
google()
jcenter()
}
}
After the above steps are set , Refresh project , recompile , There may be an error when running , Tips odex beyond 65536, Generally, you need to add the following settings .
stay Module Of app Below build.gradle Found in defaultConfi Join in multiDexEnabled = true
And in dependencies Add in
implementation 'com.android.support:multidex:1.0.0'
版权声明
本文为[osc_ydeb2o99]所创,转载请带上原文链接,感谢
边栏推荐
- Suning's practice of large scale alarm convergence and root cause location based on Knowledge Map
- Front end code style practice prettier + eslint + git hook + lint staged
- TiDB x 微众银行 | 耗时降低 58%,分布式架构助力实现普惠金融
- Ali, Tencent, Baidu, Netease, meituan Android interview experience sharing, got Baidu, Tencent offer
- Glsb involves load balancing algorithm
- Show profile analysis of SQL statement performance overhead
- Kubernetes业务日志收集与监控
- Where should wild card SSL certificate register and apply
- 使用TreeView树型菜单栏(递归调用数据库自动创建菜单)
- 接口测试如何在post请求中传递文件
猜你喜欢
Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way
Android NDK 开发实战 - 微信公众号二维码检测
Open source ERP recruitment
Fedora 33 Workstation 的新功能
深圳C1考证历程
An attempt to read or write to protected memory occurred using the CopyMemory API. This usually indicates that other memory is corrupted.
inet_ Pton () and INET_ Detailed explanation of ntop() function
From coding, network transmission, architecture design, Tencent cloud high quality, high availability real-time audio and video technology practice
A simple ability determines whether you will learn!
Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
随机推荐
Detailed explanation of [golang] GC
Stack & queue (go) of data structure and algorithm series
Is SEO right or wrong?
Android 复选框 以及回显
共创爆款休闲游戏 “2020 Ohayoo游戏开发者沙龙”北京站报名开启
Show profile analysis of SQL statement performance overhead
Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
Gather in Beijing! Openi / O 2020 Qizhi Developer Conference enters countdown
利用 Python 一键下载网易云音乐 10W+ 乐库
nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)
分库分表的 9种分布式主键ID 生成方案,挺全乎的
SQL语句实现水仙花数求取
Introduction to zero based im development (4): what is message timing consistency in IM systems?
微信圈子
20201107第16课,使用Apache服务部署静态网站;使用Vsftpd服务传输文件
AI应届生年薪涨到40万了,你现在转行还来得及!
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:樊文凯
如何用函数框架快速开发大型 Web 应用 | 实战
Android权限大全
FGC online service troubleshooting, this is enough!