当前位置:网站首页>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
- 真正拖垮你的,是沉没成本
- 10款必装软件,让Windows使用效率飞起!
- JVM学习(四)-垃圾回收器和内存分配
- Shoes? Forecasting stock market trends? Taobao second kill? Python means what you want
- inet_ Pton () and INET_ Detailed explanation of ntop() function
- JVM learning (5) - execution subsystem
- vscode 插件配置指北
- 手写Koa.js源码
- [design pattern] Chapter 4: Builder mode is not so difficult
猜你喜欢
Depth analysis based on synchronized lock
JVM learning (4) - garbage collector and memory allocation
理解 OC 中 RunLoop
外贸自建网站域名的选择— Namesilo 域名购买
On the calculation of non interaction polarizability
利用 Python 一键下载网易云音乐 10W+ 乐库
Python zero basics tutorial (01)
为wget命令设置代理
使用CopyMemory API出现 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:樊文凯
随机推荐
Introduction to zero based im development (4): what is message timing consistency in IM systems?
PAT_甲级_1074 Reversing Linked List
How to query by page after 10 billion level data is divided into tables?
Android权限大全
New features of Fedora 33 workstation
On the calculation of non interaction polarizability
使用rem,做到屏幕缩放时,字体大小随之改变
Setting up a proxy for the WGet command
SQL语句实现水仙花数求取
JVM learning (4) - garbage collector and memory allocation
Sql分组查询后取每组的前N条记录
jsliang 求职系列 - 08 - 手写 Promise
Ali, Tencent, Baidu, Netease, meituan Android interview experience sharing, got Baidu, Tencent offer
Python零基础入门教程(01)
《内网安全攻防》配套视频 之 利用PS查询域内信息
接口测试如何在post请求中传递文件
JVM学习(六)-内存模型和线程
阿里、腾讯、百度、网易、美团Android面试经验分享,拿到了百度、腾讯offer
Gather in Beijing! Openi / O 2020 Qizhi Developer Conference enters countdown
Explain Python input() function: get user input string