Configure eclipse to use my own Android SDK (frame

2019-01-23 10:04发布

问题:

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

回答1:

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:

  1. Find you new build sdk zip (for Linux it cab be found here out/host/linux-x86/sdk/)
  2. Unzip this pack into a folder
  3. Inside this folder you can find the directory which is called platforms/android-2.3.3
  4. Rename folder android-2.3.3 to <your_name>
  5. Copy this folder into the following location of the installation of your SDK Manager: android-sdk-linux/platforms
  6. Find inside this folder file build.prop and assign to the property ro.build.version.sdk any negative number: ro.build.version.sdk=-10
  7. 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.


回答2:

Try this:

  • create new floder in your project put floder name="libs"
  • and include the library here.
  • And Run the app
  • I hope it's working


回答3:

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:

  1. Project Settings > Modules > click Dependencies tab > click "+" button > select "JARs or Directories"
  2. Find the .jar and choose it
  3. Move the .jar on top of the list of Dependencies (even before the SDK)
  4. 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.)