How to correctly include the support library in no

2019-01-26 12:24发布

问题:

I am thinking how to get Android' s support library to include and compile outside Eclipse. I am using Linux as my build environment and I am not using any IDE for creating apps, only the basic Android SDK. I have only come over answers to this question regarding Eclipse, but how can I do it using only Ant and Android SDK?

回答1:

Assuming that you are not using GridLayout:

Step #1: Copy android-support-v4.jar or android-support-v13.jar from your SDK into the libs/ directory of your project.

Step #2: There is no step #2.

Choose android-support-v13.jar if you are using native fragments (versus the Android Support package's own backport) and you want to use them with things like ViewPager that are part of the Android Support package.

GridLayout makes things a bit more complicated, in that it is an Android library project. You would need to follow the instructions for how to use an Android library project in a command-line project, probably working off of a copy of the official project.

All of this stuff can be found in the extras/ directory of wherever your SDK is installed.



回答2:

Similar to this automation article http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html

Make sure to generate a valid build.xml file for ant/android building android update project --path /path/to/project

then just ant clean debug

You can also checkout the official doc http://developer.android.com/tools/building/building-cmdline.html