How to add external jar libraries to an android project from the command line

后端 未结 9 1626
猫巷女王i
猫巷女王i 2020-11-28 08:23

I\'m trying to build an Android project that has some dependencies. The jar files are in the lib/ directory. I can build the project by adding those jar file to my classpa

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 09:18

    At compiling do this:

    javac -encoding ascii -target 1.5 -d bin/classes \
    -bootclasspath $SDKDIR/android.jar src/some/project/* -classpath=libs/*.jar
    

    And, when you are generating the bytecode for Dalvik:

    dx --dex --output=bin/classes.dex bin/classes libs/*.jar
    

    Also, when you are packaging the APK file:

    apkbuilder bin/something.apk -z bin/projectname.ap_ \
    -f bin/classes.dex -rf src -rj libs
    

    I'm assuming you are using Linux... on Windows will be almost the same.

提交回复
热议问题