I downloaded the android source and did couple of changes in the framework and added some new methods. Now I am trying to develop an application to test the new changes, I am using eclipse and It points to the original sdk ( the one included in the android sdk-eclipse bundle ), how can I change the project's setting to make it look at the new built source ?
-
I've described the process in details here: http://stackoverflow.com/questions/14729793/configure-eclipse-to-use-my-own-android-sdk-framework-jar/14747707#14747707 Hope this will help you. – Yury Jan 08 '14 at 17:10
3 Answers
The problem is that eclipse doesn't have a clue what you have done to your own personal build. In order to get eclipse to recognize those changes, you need to load your OWN framework jar before the aosp SDK.
When you build AOSP, it should generate a file here:
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar
This is a jar file containing all the methods generated by aosp, including the ones labeled @hide. Include that in your project's build path, and under Order and Export make sure that it is loaded first.
There is an excellent guide which details the internal and hidden parts of how the android.jar (the sdk) works and how you can load in a different jar for your projects. If you don't want to use the method I describe above about pulling it from the out directory in your aosp tree, you can also pull it off the device to ensure you are using the exact set of classes that is available to apps on your device. From part 2:
adb pull /system/framework/framework.jar
But without additional information as to what you are changing, I can't give much more advice than this. If you read the entire guide, it will explain why if you made changes to internal, you still won't be able to get eclipse to recognize those changes without some extra work.

- 4,598
- 4
- 35
- 54
-
It didn't work, it still cant identify my new API. It asked me for the sources but I didnt know what to attach. – Foad Rezek Jan 04 '14 at 14:52
-
@FoadRezek What have you changed exactly? If you have included the built classes-full jar file in your build path, and moved it to the top of the list in order and export, it should work and you should not have build issues. If it doesn't, then something else is wrong and we need more information to help you. – Andrew T. Jan 06 '14 at 18:59
-
@FoadRezek If it asked you for sources i'm assuming it threw an error message at you as well? That may also be useful information along with what you changed. – Andrew T. Jan 06 '14 at 19:03
-
I added the jar file and moved it to the top, applied changes, I got no errors, simply the new API I am using is not recognized. for example : added a method called injectEvent() to hardwares/systemsensormanager.java, this is the kind of error I still have: "The method injectEvent(SensorEvent) is undefined for the type SensorManager" – Foad Rezek Jan 10 '14 at 11:46
-
So I added the method public injectEvent() (I added the @hide tag) to SystemSesnorManager.java, built AOSP, and included the class-full jar like I said in my project, moved it to the top, and eclipse recognized the method. You are missing a step, or not giving me enough information to help any more than this. The only other issues I can think of are that you are putting the method into one of SystemSensorManager's many inner classes by mistake. If you get more information, let me know and I'll try and help you further. – Andrew T. Jan 10 '14 at 15:58
-
Finally its solved, it appears that since the first time I tried your solution I did not refresh the application project, once I did it worked :D. you deserve a big thanks man. A small question : is it possible to attach source code for the new API too ? ( so when I hit ctrl + left mouse click I can see the source code ...) – Foad Rezek Jan 10 '14 at 20:47
-
@FoadRezek No problem glad to hear you got it working! As for your second question I am not sure, but I believe it is possible. There is a make sdk command (I've seen reference to it in some google groups) but i have never personally used it. I imagine using make sdk and adding JDoc comments to your method should be sufficient, but it would probably take a bit more research. Good luck with aosp development! – Andrew T. Jan 10 '14 at 22:10
Go to:
Window -> Preferences -> Android and browse to the SDK folder.
in Eclipse
Then change your manifest to:
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="19"
android:maxSdkVersion="19" />
If you properly guard any new api calls, you can lower your minSdk

- 1,239
- 1
- 13
- 20
-
The problem is that I cant locate the SDK folder in under my out dir. I tried to use: find -name "sdk" and I got the following results : ./host/common/obj/JAVA_LIBRARIES/sdk_common_intermediates/classes/com/android/ide/common/sdk ./target/common/docs/doc-comment-check/tools/sdk ./target/common/docs/doc-comment-check/intl/ja/sdk ./target/common/docs/doc-comment-check/sdk For each one of them when I try to add this sdk folder I get the error : Could not find folder 'tools' inside SDK. – Foad Rezek Dec 27 '13 at 11:09
-
It won't be stored inside your project. You have to download it from the internet. If you haven't, it's here: https://developer.android.com/sdk/index.html – Gabe Dec 27 '13 at 16:29
-
how MY new API should show in the default SDK ??! I want to see my new changes I added to the android framework by changing the android source. I downloaded API 17, changed it and now I want to use the modifed API 17. I dont know what is your goal of using the original sdk – Foad Rezek Dec 28 '13 at 08:38
I'm no expert, but I think you may need to use something like ant, maven or gradle, as opposed to just using eclipse.

- 51
- 6