简体   繁体   English

使用库项目编译android项目失败,缺少classes.jar

[英]Compiling android project with a library project fails with missing classes.jar

I'm making an app that depends on the Android v7 appCompat support library. 我正在制作一个依赖于Android v7 appCompat支持库的应用程序。 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. 当我尝试使用Ant构建项目时,从dex收到一条错误消息,指出它无法从appCompat项目的bin目录中找到文件classes.jar。 Here's what I have done: 这是我所做的:

  1. I copied the appCompat directory under the SDK over to my project. 我将SDK下的appCompat目录复制到了我的项目中。 It is now one of the top-level directories along with libs, res, src etc. 现在,它与libs,res,src等一起是顶级目录之一。
  2. 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.) (--target 1指的是我系统上的api级别22。)

  3. I generated build files for the appCompat project: 我为appCompat项目生成了构建文件:

     cd appCompat android update lib-project --target 1 --path . 
  4. 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. 实际上,appCompat \\ bin中没有class.jar。 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. 实际上,在查看了整个构建输出之后,似乎从未构建过这样的东西,但Ant似乎希望它存在。

Is there something I'm missing here? 我在这里想念什么吗? Any help would be greatly appreciated. 任何帮助将不胜感激。

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. 如果您要手动设置所有内容,则可以通过在[your project]/appCompat/project.properties文件中添加android.library=true来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM