当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Where should wild card SSL certificate register and apply
- 一个简单的能力,决定你是否会学习!
- Mac terminal oh my Zsh + solarized configuration
- 050_ object-oriented
- 从编码、网络传输、架构设计揭秘腾讯云高质量、高可用实时音视频技术实践...
- PAT_甲级_1074 Reversing Linked List
- Handwriting Koa.js Source code
- A simple way to realize terminal text paste board
- Recommended tools for Mac
- SQL第二章第三章
猜你喜欢
Wechat circle
The choice of domain name of foreign trade self built website
Detailed explanation of [golang] GC
关于无相互作用极化率的计算
How to ensure that messages are not consumed repeatedly? (how to ensure the idempotent of message consumption)
Well, the four ways to query the maximum value of sliding window are good
从编码、网络传输、架构设计揭秘腾讯云高质量、高可用实时音视频技术实践...
2020.11.07面试总结(面试12k)
Front end code style practice prettier + eslint + git hook + lint staged
Looking for better dynamic getter and setter solutions
随机推荐
手写Koa.js源码
Dynamo: a typical distributed system analysis
SEO见风使舵,是对还是错?
接口测试如何在post请求中传递文件
Front end code style practice prettier + eslint + git hook + lint staged
Tidb x micro banking reduces time consumption by 58%, and distributed architecture helps to realize inclusive finance
JVM learning (5) - execution subsystem
Android Studio Avd「真·小白食用方法」
Android架构之Navigation组件(二)
Understanding runloop in OC
inet_ Pton () and INET_ Detailed explanation of ntop() function
JVM学习(六)-内存模型和线程
inet_pton()和inet_ntop()函数详解
在嵌入式设备中实现webrtc的第三种方式③
深圳C1考证历程
为wget命令设置代理
TiDB x 微众银行 | 耗时降低 58%,分布式架构助力实现普惠金融
外贸自建网站域名的选择— Namesilo 域名购买
JVM learning (6) - memory model and thread
Depth analysis based on synchronized lock