当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- As a user, you can't get rid of the portrait!
- Safety (miscellany)
- Mapstructure detoxifies object mapping
- android studio创建平板模拟器方法
- 为wget命令设置代理
- 接口测试如何在post请求中传递文件
- Python zero basics tutorial (01)
- 开源ERP招聘了
- 在嵌入式设备中实现webrtc的第三种方式③
- Introduction to zero based im development (4): what is message timing consistency in IM systems?
猜你喜欢

Setting up a proxy for the WGet command

JVM学习(六)-内存模型和线程

nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)

Tidb x micro banking reduces time consumption by 58%, and distributed architecture helps to realize inclusive finance

Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive

SHOW PROFILE分析SQL语句性能开销

零基础IM开发入门(四):什么是IM系统的消息时序一致性?

使用TreeView树型菜单栏(递归调用数据库自动创建菜单)

JVM learning (4) - garbage collector and memory allocation

The choice of domain name of foreign trade self built website
随机推荐
使用TreeView树型菜单栏(递归调用数据库自动创建菜单)
Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
The third way to realize webrtc in embedded devices
大型项目Objective-C - NSURLSession接入短信验证码应用实例分享
安全(杂记)
vscode 插件配置指北
Impact of libssl on CentOS login
jsliang 求职系列 - 08 - 手写 Promise
使用CopyMemory API出现 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
未来中国电信将把云计算服务打造成为中国电信的主业
Review of hot spots of last week (11.2-11.8)
Pay attention to the request forwarding problem of. Net core
微信圈子
nodejs学习笔记(慕课网nodejs从零开发web Server博客项目)
inet_pton()和inet_ntop()函数详解
Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way
Three practical skills of Medical Project Management
从编码、网络传输、架构设计揭秘腾讯云高质量、高可用实时音视频技术实践...
AndroidStudio导入定制化的framework classess.jar AS 4.0.1版本亲测有效
走进京东 | 中国空间技术研究院青年创新联盟成员莅临参观京东总部