android应用程序访问隐藏的api

来源:互联网 发布:华润网络深圳有限公司 编辑:程序博客网 时间:2024/04/29 20:09

前言

在android系统开发中需要添加一些aidl文件。 这些aidl是hide的,应用程序无法直接的使用,从而引出了应用程序如何访问内部内藏的api接口

步骤

1.android在编译完成后,会生成framework.jar。难道应用程序要使用这个framework.jar吗?
其实不是的,需要使用的是

out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/class.jar

这个class.jar文件
2.在android studio中,将这个class.jar作为一个module加入工程

File->Project structure -> +(左上角) > 选择 import .jar (导入jar包)-> Moduless下出现classes -> 选择app下 dependencise -> + (右上角)> 添加 module,选择添加的classes,同时将compile 修改为provides
3. 在app下的build.gradule下添加 dexOptions {
javaMaxHeapSize “4g”
}

4.在工程app下的android defaultconfig 下添加 mutiDexEnabled true
5. app下 dependencies {
compile ’com.android.support:multidex:1.0.0‘
}
6.在Minifest application 中添加
android:name =”android.support.multidex.MultiDexApplication”

总结

在android系统开发中通过这样的方式,就可以访问一些内部的接口文件。

参考文献

How do I build the Android SDK with hidden and internal APIs available?
Creating a module library and adding it to module dependencies
Android Studio Google jar causing GC overhead limit exceeded error
Building Apps with Over 65K Methods

0 0
原创粉丝点击