问题
I'm making an app that depends on the Android v7 appCompat support library. When I'm trying to build the project with Ant, I get an error from dex stating that it can't find the file classes.jar from the appCompat project's bin directory. Here's what I have done:
- I copied the appCompat directory under the SDK over to my project. It is now one of the top-level directories along with libs, res, src etc.
I added the library to my project:
android update project --target 1 --path . --library .\appCompat
(--target 1 refers to api level 22 on my system.)
I generated build files for the appCompat project:
cd appCompat android update lib-project --target 1 --path .
I went back to my project and attempted building it:
cd .. ant clean debug
Everything goes smoothly until I get the following:
-dex: [dex] input: C:\Users\Tuukka\Documents\app\bin\classes [dex] input: C:\Users\Tuukka\Documents\app\appcompat\bin\classes.jar [dex] input: C:\Users\Tuukka\Documents\app\appcompat\libs\android-support-v4.jar [dex] input: C:\Users\Tuukka\Documents\app\appcompat\libs\android-support-v7-appcompat.jar [dex] Pre-Dexing C:\Users\Tuukka\Documents\app\appcompat\libs\android-support-v4.jar -> android-support-v4-7d4b9d18b52617b1310b8c2397abe6b7.jar [dex] Pre-Dexing C:\Users\Tuukka\Documents\app\appcompat\libs\android-support-v7-appcompat.jar -> android-support-v7-appcompat-af2360631cde3dc57c1fde6f23204ddb.jar [dex] Converting compiled files and external libraries into C:\Users\Tuukka\Documents\app\bin\classes.dex... [dx] [dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.io.FileNotFoundException: C:\Users\Tuukka\Documents\app\appcompat\bin\classes.jar (No such file or directory)
There is indeed no classes.jar in appCompat\bin. In fact, after looking through the entire build output, it seems such a thing was never built, yet Ant seems to expect that it exists.
Is there something I'm missing here? Any help would be greatly appreciated.
回答1:
I think this problem is caused by the project not being set up as a library project. If you are setting up everything by hand you can fix this by adding android.library=true
to the [your project]/appCompat/project.properties
file.
来源:https://stackoverflow.com/questions/29766740/compiling-android-project-with-a-library-project-fails-with-missing-classes-jar