Android 11 修改libcore Cipher AS测试

1.从Project\out\target\common\obj\JAVA_LIBRARIES\core-oj.com.android.art.debug_intermediates 拷贝classes.jar 到Android studio lib目录

Android 11 修改libcore Cipher AS测试

2.在Module下的build.gradle添加

dependencies {
    implementation files('libs\\classes.jar')

3、在Project下的build.gradle文件的 allprojects 标签内中添加

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs.add('-Xbootclasspath/p:app/libs/classes.jar')
        }
    }

4.Module下的build.gradle的末尾处添加,修改优先级:

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
        }
    }
}

5.修改Jar包优先顺序.idea/modules/app/ProjectName.iml , 把classes.jar 顺序调至原生API之上。

Android 11 修改libcore Cipher AS测试

6.测试API调用的返回值,OK

Android 11 修改libcore Cipher AS测试

 

 

上一篇:MariaDB基本知识点总结


下一篇:java学习笔记(五)Defining Classes II