0

I am trying to build my app (uses many hidden api and properties) in android studio. I have modified the AOSP code to expose these hidden apis. In order to make the build successful I have added the classes.jar as the external lib to my project. But that doesn't resolve the issue. It was still showing errors :

error: cannot find symbol method getService()   
error: cannot find symbol variable userSetLocale    
error: cannot find symbol method getInstance()  
error: cannot find symbol variable INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH  
error: cannot find symbol variable INJECT_INPUT_EVENT_MODE_ASYNC    

Now I am trying to make the custom SDK with this modified AOSP code.

Note : Already tried and failed with the following solutions

Can anyone help to build custom SDK based on the modified AOSP code

Edric
  • 24,639
  • 13
  • 81
  • 91

2 Answers2

0

Add the following in you root project's build.gradle. ${rootDir}/libs/framework.jar is the jar build from you aosp code.

subprojects {
gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs.add("-Xbootclasspath/p:${rootDir}/libs/framework.jar")
    }
 }
}

There are red errors in the editor. But it can be build successful. Demo project:https://github.com/auxor/AppWithModifiedFramework/

Yong
  • 1,529
  • 12
  • 21
  • This solution works for me. And can you check whether the classes.jar is right? Does the classes.jar contains the modified hidden api? – Yong Jan 07 '20 at 02:15
  • It works if you add a new class. It doesnt work for hidden methods on classes that are already exposed in normal SDK (android.jar). For example you cannot add a method or class to Activity or Context with this approach. The only way is to replace the android.jar in SDK folder – Rick Sanchez Jan 07 '20 at 14:17
  • @RickSanchez I have add new api for already exposed classes in Android 5.0. It works. – Yong Jan 08 '20 at 01:59
  • Wierd. It did not for me when I tried this about a month ago. If you have time, can you post a simple android project in github complete with the framework.jar and any other relevant changes to build.gradle that make it work? It'd be pretty useful if you found a way to make it work without replacing android.jar. – Rick Sanchez Jan 08 '20 at 07:04
  • @RickSanchez https://github.com/auxor/AppWithModifiedFramework/ – Yong Jan 09 '20 at 02:46
  • I don't have issue with the framework.jar. But during build time, it is still referring to the api from the SDK not from the framework.jar. I have changed the orderEntry of SDK to the last in app.iml. But after gradle sync it is again changed to default. – MUHAMMED RAFEEQ KARAKKADAN Jan 09 '20 at 06:29
  • Studio is able to resolve custom changes in framework.jar. But while building i get compile error says cannot resolve method. Any help ? – MUHAMMED RAFEEQ KARAKKADAN Jan 09 '20 at 06:43
  • @MUHAMMEDRAFEEQKARAKKADAN I have no idea about why it does not work for you. You may have a look at github.com/auxor/AppWithModifiedFramework. – Yong Jan 09 '20 at 07:19
  • @Yong Are you sure your project builds successful after hidden api or property is used? I have added these lines in your project : Configuration config = am.getConfiguration(); config.userSetLocale = true; after this the build failed with error : cannot find symbol variable userSetLocale – MUHAMMED RAFEEQ KARAKKADAN Jan 14 '20 at 05:11
  • @MUHAMMEDRAFEEQKARAKKADAN Do you have any error, when you don't modify anything? ActivityManager.addMode and ActivityManager2 are new added API. And ActivityManager don't have method getConfiguration – Yong Jan 14 '20 at 05:37
  • @MUHAMMEDRAFEEQKARAKKADAN In the editor, it may show red error. But it can be build successful. Try "./gradlew assemble" in the terminal or Run it. – Yong Jan 14 '20 at 05:47
0

I solved the issue by changing the orderEntry of sdk in app.iml and giving the absolute path of framework.jar in modules build.gradle