英文:
How to use AntlrV4 in Android Project
问题
我在我的Android项目中似乎无法让antlr4正常工作,当使用IntelliJ的Antlr4插件时,将词法分析器分配给一个val时会引发此错误:
无法反序列化版本为4的ATN(期望为3)。
我还在我的build.gradle中导入了Antlr4运行时v4.9,如果我没记错的话。Antlr4插件显示它是v4.12?这可能是问题吗?当它说期望3时,我感到困惑。插件不应该生成V4词法分析器和解析器吗?我对Antlr非常陌生,谷歌在寻找解决方法时并没有帮助。
英文:
I cannot seem to get antlr4 working in my android Project, when using the Antlr4 plugin for intellij. When assigning the lexer to a val it throws this error
Could not deserialize ATN with version 4 (expected 3).
I'm also importing the Antlr4 runtime in my build.gradle v4.9 iirc. The Antlr4 plugin says it's v4.12? Could that be the issue? I was thrown off when it said expected 3. Should it not be generating V4 lexer and parser with the plugin? I'm very new to Antlr and Google hasn't been fruitful in my search to solve this.
答案1
得分: 0
感谢kaby76,版本确实是问题所在。插件是4.12版本,因此更新实现为"org.antlr:antlr4-runtime:4.12.0"就解决了问题。
英文:
Thanks to kaby76, the versions were indeed the problem. the plugin is 4.12, so updating the implementation to implementation "org.antlr:antlr4-runtime:4.12.0" did the trick
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论