Android: List.of() (API 30+) used in core since 0.24.0 contradicts the README's "minimum API level is 19"
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- mobile-dev
调研方向
首先检查 commonmark 模块中列出的 List.of、Set.of 和 Map.of 用法,以及 .github/workflows/ci.yml 中的 Android 测试设置。在不使用 core library desugaring 的情况下复现 API 24–29 的失败,然后验证所选解决方案是否能使 README、运行时行为和 Android 支持预期保持一致。
由索引模型根据 Issue 内容生成。
描述
Summary
Since 0.24.0 the core commonmark module uses java.util.List.of(...) (and a few Set.of/Map.of). On Android these methods exist only from API 30 (Android 11). The README still says:
It works on Android too, but that is on a best-effort basis, please report problems. For Android the minimum API level is 19
An app with minSdk < 30 that does not enable core library desugaring crashes on the first parse on API < 30 devices:
java.lang.NoSuchMethodError: No static method of(Ljava/lang/Object;)Ljava/util/List;
at org.commonmark.internal.InlineParserImpl.parse(InlineParserImpl.java)
This is the same class of problem as #366 / #373 (Objects.requireNonNullElseGet, fixed by #369). The List.of usages were introduced deliberately in #322 as a Java 11 clean-up, so this is a report that the clean-up and the Android support statement now disagree — not a claim that the change was wrong.
Steps to reproduce
Android app, minSdk 24, no coreLibraryDesugaring, org.commonmark:commonmark:0.30.0, run on an API 24–29 emulator:
Parser.builder().build().parse("*a*") // NoSuchMethodError: List.of
With isCoreLibraryDesugaringEnabled = true + com.android.tools:desugar_jdk_libs:2.1.5 the same code works on API 24 (verified on an API 24 emulator).
Where the API 30+ calls live (0.30.0, commonmark module)
List.of / Set.of / Map.of occurrences by file:
| File | Count |
|---|---|
internal/InlineParserImpl.java |
8 |
renderer/markdown/CoreMarkdownNodeRenderer.java |
3 |
renderer/html/CoreHtmlNodeRenderer.java |
3 |
parser/Parser.java |
3 (incl. Javadoc example) |
internal/ParagraphParser.java |
2 |
internal/IndentedCodeBlockParser.java |
2 |
renderer/text/CoreTextContentNodeRenderer.java, renderer/markdown/MarkdownRenderer.java, renderer/html/HtmlWriter.java, renderer/html/DefaultUrlSanitizer.java, parser/block/AbstractBlockParser.java, node/SourceSpans.java |
1 each |
0.22.0 had none; 0.24.0 introduced 8 in InlineParserImpl.
Why CI did not catch it
commonmark-android-test is only run through ./gradlew :app:lint in .github/workflows/ci.yml (minSdk 19, no emulator run), so a runtime NoSuchMethodError never surfaces there.
Possible resolutions
Either would be fine from a consumer's point of view — the important part is that the README and the code agree:
- Keep API 19 support — replace the factory calls with Java 8 equivalents (
Collections.emptyList()/singletonList(x)/unmodifiableList(Arrays.asList(a, b)), same forSet/Map). Mechanical, ~26 sites, keeps immutability. I can send a PR if you want this. - Document the new requirement — state in the README that Android needs API 30+ or core library desugaring, and ideally have
commonmark-android-testrun on an emulator (or fail lint onNewApi) so future regressions are visible.
Context: I hit this while building an Android Markdown renderer on top of commonmark-java (https://github.com/Jimmy-Jung/RichMarkdown-Android). We chose minSdk 30 for now, so this is not blocking us — reporting because the README statement is likely to mislead other Android users.
- 主要语言
- Java
- 星标
- 2.7k
- 派生
- 337
- 平均合并
- 15 天 9 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
commonmark/commonmark-java 的其他 Issue
-
Unclosed link reference definition title keeps the partial title and the following paragraph's source spans (0.30.0)可能已有人在做 @sean0407 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
commonmark/commonmark-java#460 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 48/100
commonmark/commonmark-java#443 · 4 条评论 ·
-
Option to define custom flanking/canOpen/canClose rules for delimiters可能重新可做 @abhiramaab 于 60 天前认领,目前没有进行中的 PR。 未关闭enhancement
难度 4/5 3-5 天 新手友好度 45/100
commonmark/commonmark-java#428 · 4 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
commonmark/commonmark-java#414 · 1 条评论 · 1 个 reaction ·
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
commonmark/commonmark-java#411 · 2 条评论 ·
查看 commonmark/commonmark-java 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
utopia-rise/godot-jvm#1004 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
resilience4j/resilience4j#2547 ·
维护者通常 9 天内回复
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid date可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1 小时以内 新手友好度 82/100
mit-cml/appinventor-sources#4155 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 62/100
Hira-shi/PW1-DAI-Carrel-Egal-Eyer#28 ·
维护者通常 1 天内回复
-
`GET /v1/event/token/{uuid}` can report a BOM upload as done before policy evaluation and metrics have finished可能已有人在做 @Zargath 今天认领。 未关闭defect in triage
难度 2/5 1-3 小时 新手友好度 72/100
DependencyTrack/dependency-track#7646 ·
维护者通常 1 天内回复