尝试在 Eclipse 中包含 Maven 构建的库,出现丢失工件错误

发布于 2025-01-06 22:41:35 字数 404 浏览 3 评论 0原文

我看到有很多关于这个问题的问题,但不幸的是没有人为我解决它。这是所发生情况的屏幕截图:

pom.xml dependency error

它依赖于 android-support-v4 jar 文件如您所见,它已添加到我的构建路径中。它是 Maven 库目录的 libs 文件夹中的确切 jar 文件。我已尝试以下操作:

  • 重新启动 Eclipse
  • 清理项目
  • 右键单击​​项目并更新依赖
  • 项 更新项目配置 禁用并重新启用工作区解析

没有任何帮助。还有其他技巧可以解决这个问题吗?我看到的所有答案都建议做我已经尝试过的这些事情。

多谢!

I've seen that there are quite a few questions regarding this problem, but unfortunately none have solved it for me. Here is a screencap of what's going on:

pom.xml dependency error

It is dependent on the android-support-v4 jar file which as you can see is added to my build path. It the exact jar file from the maven library directory's libs folder. I've tried the following:

  • Restarting Eclipse
  • Cleaning the project
  • Right-clicking the project and updating dependencies
  • Updating project configuration Disabling and re-enabling workspace resolution

Nothing has helped. Is there any other tricks to getting this resolved? All of the answer's I've seen suggest doing these things that I have already tried.

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡離愁欲言轉身 2025-01-13 22:41:35

实际根本原因:

OP JMRboosties 报告在此实例中必须停用Proguard(缩小、优化和通过删除未使用的代码并使用语义上晦涩的名称重命名类、字段和方法来混淆代码)

pom.xml中发生错误的行(项)禁用proguard解决了问题

(请参阅“如何将 ProGuard 与 android-maven-plugin 一起使用")。

使用 Proguard 可能会产生某些副作用:例如,Proguard 页面 确实提到:

默认的 proguard.cfg 文件尝试涵盖一般情况,但您可能会遇到异常,例如 ClassNotFoundException,当 ProGuard 剥离应用程序的整个类时会发生这种情况来电。


原始答案:

正如GitHub帖子中提到的:

我将把我自己的 Android 工件部署到我的个人存储库,以避免再次出现此问题。
如果您没有明确使用 Maven,您可以将其作为常规 Android 项目导入到 eclipse 中,它会从 libs/ 目录中获取 .jar。 /p>

(请注意,您的 android-support-v4.jar 不在项目的 libs 中)

您现在必须使用 Maven SDK 部署程序安装 Android 1.6 和兼容库

cd 到 deployer 中的 platforms/platform-4/extras/compatibility-v4/ 并运行 mvn install< /code> 在每个中。

希望 compat lib 尽快进入 Maven 中心,这样我就可以避免这一步。

同样,该项目被设置为在 Eclipse 中用作普通 Android 项目,与 maven 完全分离。
文件、新建、项目、Android,使用现有源,选择library/文件夹。

Actual root cause:

The OP JMRboosties reports in this instance having to desactivate Proguard (the tool which shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names)

disabling proguard on the line where the error occurred (the <plugin> item) in pom.xml solved the problem

(See "How to use ProGuard with android-maven-plugin ").

Certain side-effects can result from using Proguard: For example, the Proguard page does mention:

The default proguard.cfg file tries to cover general cases, but you might encounter exceptions such as ClassNotFoundException, which happens when ProGuard strips away an entire class that your application calls.


Original answer:

As mentioned in this GitHub post:

I'm going to deploy my own android artifacts to my personal repository to avoid having this problem again.
If you're not explicitly using Maven you can just import it as a regular Android project into eclipse and it'll pick up the .jar from the libs/ directory.

(Note your android-support-v4.jar isn't in libs in your project)

You have to install both Android 1.6 and the compat lib using the maven SDK deployer for now.

cd to platforms/platform-4/ and extras/compatibility-v4/ in the deployer and run mvn install in each.

Hopefully the compat lib makes it into maven central soon so I can avoid this step.

Again, the project is set up to be used as a normal Android project in eclipse too completely separate from maven.
File, New, Project, Android, use existing sources, select library/ folder.

一曲爱恨情仇 2025-01-13 22:41:35

假设您在幕后使用 m2e-android,那么您遇到编译问题的原因是 m2e-android 插件从 Eclipse 项目类路径中删除了所有provided范围依赖项。

我们这样做是因为,由于 ADT 16.0.0 中的更改,Eclipse 类路径中的任何 JAR 文件都将打包到可分发的 APK 文件中。

Assuming you're using m2e-android behind the scenes, the reason you're getting compile problems is that the m2e-android plug-in strips out all provided scope dependencies from the Eclipse project classpath.

We do this because, due to changes in ADT 16.0.0, any JAR file in the Eclipse classpath will be packaged into distributable APK file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文