R8:IR 转换期间出现 NullPointerException
Posted
技术标签:
【中文标题】R8:IR 转换期间出现 NullPointerException【英文标题】:R8: NullPointerException during IR Conversion 【发布时间】:2020-07-16 02:13:37 【问题描述】:我在尝试生成应用的发布版本时遇到问题。它给出了一个奇怪的错误
C:\Users\rshal\.gradle\caches\transforms-2\files-2.1\6c326691eb00442622017dd95f96e92a\jetified-firebase-config-19.1.3-runtime.jar: R8: NullPointerException during IR Conversion
> Task :app:minifyProdReleaseWithR8 FAILED
我一直在使用 firebase 分析和 firebase 远程配置,没有任何问题。而且我对这个 R8 最小化没有任何问题。
最近我集成了google-speech-api
,之后我就无法使用R8了。
在我将google-speech-api
集成到应用程序中之前,我没有遇到这个问题。我知道 google-speech-api
在 android 上不受官方支持。或许这才是核心问题。在此之前,我遇到了 firebase-config
依赖问题。我认为它与google-speech-api
库不兼容。我用这个 Gradle 配置解决了这个问题
implementation('com.google.firebase:firebase-config',
exclude group: 'com.google.protobuf' // google-cloud-speech causes this. see https://github.com/firebase/firebase-android-sdk/issues/1143
)
我已关注this 修复。
现在我被上面显示的这个错误所困扰。
按照here 的建议,我在 R8 上尝试了不同的版本
这是 gradle 构建日志
> Task :app:minifyProdReleaseWithR8
R8: Missing class: org.apache.logging.log4j.spi.ExtendedLoggerWrapper
R8: Missing class: org.eclipse.jetty.npn.NextProtoNego$ClientProvider
R8: Missing class: javax.servlet.ServletContextListener
R8: Missing class: org.jboss.marshalling.ByteOutput
R8: Missing class: java.lang.ClassValue
R8: Missing class: org.eclipse.jetty.alpn.ALPN$ClientProvider
R8: Missing class: org.jboss.marshalling.ByteInput
R8: Missing class: org.eclipse.jetty.alpn.ALPN$ServerProvider
R8: Missing class: org.eclipse.jetty.npn.NextProtoNego$ServerProvider
R8: Library class android.net.http.AndroidHttpClientConnection implements program class org.apache.http.HttpInetConnection
R8: Library class android.net.http.AndroidHttpClientConnection implements program class org.apache.http.HttpConnection
C:\Users\rshal\.gradle\caches\transforms-2\files-2.1\6c326691eb00442622017dd95f96e92a\jetified-firebase-config-19.1.3-runtime.jar: R8: NullPointerException during IR Conversion
> Task :app:minifyProdReleaseWithR8 FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyProdReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complet
这是build.gradle
file
this 是*** Gradle 文件
【问题讨论】:
您找到解决方案了吗? 我没有。我认为这是与 r8 相关的错误。我打算提交一个错误报告。我准备了最小的 Gradle 配置来重现此错误。如果你愿意,我可以分享 是的,我非常想要) 您使用的是什么版本的成绩插件?这真的很重要 我用的是3.6.2版本 【参考方案1】:回答我自己的问题,因为它原来是一个R8
错误,在我报告它之后,他们解决了这个问题。太棒了。
完整的错误报告以及如何应用修复是here
短版:
将gradle
配置更改为此
buildscript
repositories
maven
url 'https://storage.googleapis.com/r8-releases/raw'
dependencies
classpath 'com.android.tools:r8:1.6.88' // Must be before the Gradle Plugin for Android.
classpath 'com.android.tools.build:gradle:3.6.2'
我在我的 Android 应用程序中实现 Google Speech API 时遇到了这个错误。
对于任何可能需要它的人,这是我最后的groguard
配置
-keep class com.google.api.gax.** *;
-keep class com.google.cloud.** *;
-keep class com.google.api.services.translate.** *;
-keep class com.google.api.client.util.** *;
-keep class com.google.api.client.googleapis.** *;
-keep class com.google.cloud.speech.v1.stub.** *;
-keep class io.grpc.** *;
-keep class com.google.auth.oauth2.** *;
-keep class com.google.auth.** *;
【讨论】:
以上是关于R8:IR 转换期间出现 NullPointerException的主要内容,如果未能解决你的问题,请参考以下文章