当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 为wget命令设置代理
- Large scale project Objective-C - nsurlsession access SMS verification code application example sharing
- Adobe experience design / XD 2020 software installation package (with installation tutorial)
- FGC online service troubleshooting, this is enough!
- New features of Fedora 33 workstation
- Open source ERP recruitment
- SHOW PROFILE分析SQL语句性能开销
- Mac terminal oh my Zsh + solarized configuration
- 【golang】GC详解
- AndroidStudio导入定制化的framework classess.jar AS 4.0.1版本亲测有效
猜你喜欢

JVM学习(五) -执行子系统

The middle stage of vivo Monkey King activity

Dynamo: a typical distributed system analysis

Ali, Tencent, Baidu, Netease, meituan Android interview experience sharing, got Baidu, Tencent offer

Android架构之Navigation组件(二)

服务应用 ClockService安卓实现闹钟

Biden wins the US election! Python developers in Silicon Valley make fun of Ku Wang in this way

TiDB x 微众银行 | 耗时降低 58%,分布式架构助力实现普惠金融

android studio AIDL的使用

注意.NET Core进行请求转发问题
随机推荐
What really drags you down is sunk costs
Configure switch trunk interface traffic local priority forwarding (cluster / stack)
Tidb x micro banking reduces time consumption by 58%, and distributed architecture helps to realize inclusive finance
The middle stage of vivo Monkey King activity
Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive
Source code analysis of ThinkPHP framework execution process
块级元素和行内元素
从编码、网络传输、架构设计揭秘腾讯云高质量、高可用实时音视频技术实践...
零基础IM开发入门(四):什么是IM系统的消息时序一致性?
libssl对CentOS登录的影响
VisualStudio(Mac)安装过程笔记
Stack & queue (go) of data structure and algorithm series
在嵌入式设备中实现webrtc的第三种方式③
Oh, my God! Printing log only knows log4j?
Android Studio Avd「真·小白食用方法」
Git delete IML file
Analysis of the source code of ThinkPHP facade
关于无相互作用极化率的计算
Program life: from Internet addicts to Microsoft, bat and byte offer harvesters
Setting up a proxy for the WGet command