【问题标题】:"Unable to find method ''void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)''"“找不到方法 ''void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)''”
【发布时间】:2021-12-13 20:17:25
【问题描述】:

问题:我目前正在使用 Android StudioGradle 从 github 存储库 (00-Evan/shattered-pixel-dungeon) 编译代码,而我可以运行一些任务(尝试过'desktop:release'、'desktop:debug'),gradle 拒绝正确同步,每​​次我尝试这样做时,都会弹出一个错误日志:

FAILURE: Build failed with an exception.

* What went wrong:
'void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)'

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
java.lang.NoSuchMethodError: 'void org.apache.commons.compress.archivers.zip.ZipFile.<init>(java.nio.channels.SeekableByteChannel)'
    at com.android.repository.util.InstallerUtil.unzip(InstallerUtil.java:99)

重要提示:我之前遇到过这个问题(在编译此代码的以前版本时),然后下载了特定版本的 SDK 构建工具(如果我记得的话,是 30.0.0 和 26.0.0正确)有帮助,但这不再有帮助了。
使用此代码的其他人没有报告同样的问题,而且我似乎是唯一一个。

由于某些原因,android 任务似乎也不起作用,好像 android studio 没有识别它们:

Task 'release' not found in project ':android'.

 * Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

我的尝试:

  • 清除缓存并重新启动 Android Studio/我的电脑
  • 启用/禁用不同的构建工具版本(参见“重要”部分)。目前我已尝试启用所有 30.0.X 和 26.0.X 版本并禁用任何已启用的较新版本
  • 浏览了类似的 Stackoverflow 线程,但是它们似乎不适用于我的情况,或者没有包含足够的信息。 Linklinklink
  • 卸载 Android Studio 并从头开始重新下载。

其他信息:

  • Android Studio 版本:Android Studio 北极狐 | 2020.3.1 补丁 4(当前最新)
  • Gradle 版本:7.2(我尝试使用 7.1.1,但没有解决问题)

【问题讨论】:

    标签: java android android-studio gradle


    【解决方案1】:

    一般情况下,安装android studio时会安装最新的SDK和最新的构建工具版本,与现有项目不兼容。

    根据00-Evan/shattered-pixel-dungeon中的build.gradle

    您应该尝试安装 SDK 版本 30。以及 SDK 构建工具版本:30.0.X。 它应该可以工作。

    对我来说,它适用于 SDK 版本 30 和构建工具版本 30.0.3。

    只要确保您拥有 build.gradle 中提到的 java 版本 8。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多