I made a custom framework.jar for my device. This new framework include a new API which I'd like to use in my apps. Unfortunately, besides I included my own framework.jar in java build path, eclipse didn't see my new API and throw compiling time errors.
How can I configure eclipse to use my custom framework.jar instead of the jar within android SDK?
[EDIT]
Based in @Yuri 's answer and some other insights, I created a tool (actually it is a shell script) to create a new platform in android SDK and merge jar files into it. It's available in XDA forums to download as well the instructions to use: http://forum.xda-developers.com/showthread.php?t=2619775
To build SDK you should run the following commands:
make update-api
make sdk
Since the API of Android has been modified the command make update-api
adds new API. The command make sdk
creates SDK in out
folder.
Then to start develop your applications in Eclipse using new SDK you should add this new SDK. There are 2 possibilities to do this. The first one is from the book "Embedded Android". I'll just copy it here:
Assuming you had already configured Eclipse for Android development
using the in‐ structions at http://developer.android.com, you’ll need
to carry out two additional steps to use your newly-built SDK. First,
you’ll need to tell Eclipse the location of the new SDK. To do so, go
to Window→Preferences→Android, enter the path to the new SDK in the
”SDK Location” box, and click OK. Also, for reasons that aren’t
entirely clear to the author at the time of this writing, you also
need to go to Window→“Android SDK Man‐ ager”, deselect all the items
that might be selected except the first two under “Tools” and click on
“Install 2 packages...” Once that is done, you’ll be able to create
new projects using the new SDK and access any new APIs you expose in
it. If you don’t do that second step, you’ll be able to create new
Android projects, but none of them will resolve Java libraries
properly and will, therefore, never build.
As for the second here it is:
- Find you new build sdk zip (for Linux it cab be found here
out/host/linux-x86/sdk/
)
- Unzip this pack into a folder
- Inside this folder you can find the directory which is called
platforms/android-2.3.3
- Rename folder
android-2.3.3
to <your_name>
- Copy this folder into the following location of the installation of
your SDK Manager:
android-sdk-linux/platforms
- Find inside this folder file
build.prop
and assign to the property
ro.build.version.sdk
any negative number:
ro.build.version.sdk=-10
- Now run SDK Manager and you'll notice that you new sdk is added.
Simply create new Eclipse project and select this sdk as a target.
This is a good question! Your tip would be useful for Android Studio users as well, I guess.
Just FYI, for IntelliJ users, you can also do this:
- Project Settings > Modules > click Dependencies tab > click "+" button > select "JARs or Directories"
- Find the .jar and choose it
- Move the .jar on top of the list of Dependencies (even before the SDK)
- Change the scope to 'Provided' (not 'Compile')
By step 4, you can avoid making a huge .dex. (Your apk will not include the framework.jar.)