Tencent / Shadow

零反射全动态Android插件框架
BSD 3-Clause "New" or "Revised" License
7.36k stars 1.29k forks source link

NoSuchMethodException: com.android.tools.apk.analyzer.BinaryXmlParser.decodeXml 错误 #1314

Closed aidaole closed 2 months ago

aidaole commented 2 months ago

基于最新的代码 image 环境: android studio 版本: Android Studio Iguana | 2023.2.1 jdk版本: 11 和17 均失败

尝试运行 sample-host./gradlew :sample-host:installDebug 一直失败, 提示错误:

> Task :sample-loader:createDebugApkListingFileRedirect
> Task :sample-loader:assembleDebug

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':sample-base:decodePluginDebugBinaryManifest'.
> java.lang.NoSuchMethodException: com.android.tools.apk.analyzer.BinaryXmlParser.decodeXml(java.lang.String, [B)

* Try:
> 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':sample-app:decodePluginDebugBinaryManifest'.
> java.lang.NoSuchMethodException: com.android.tools.apk.analyzer.BinaryXmlParser.decodeXml(java.lang.String, [B)

* Try:
> 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.
==============================================================================
shifujun commented 2 months ago

如果是最近build tools更新了,导致找不到这个方法,我们就得重新适配了。你可以看下版本号,我看看能不能复现。

也可以按 https://github.com/Tencent/Shadow/blob/master/CONTRIBUTING.md 中的说明去debug gradle插件。加log也是个选择。

相关逻辑可以搜索commit message找到。

aidaole commented 2 months ago

问题已经找到, 是因为我的电脑上配置了Flutter的环境, 将 android sdk home\cmdline-tools\latest 配置到了环境变量中, 导致 com.android.tools.apk.analyzer.BinaryXmlParser 加载错误了. 把环境变量删除之后可以正常编译了