gpt4 book ai didi

android - D8 : Type `sun.misc.Unsafe` was not found

转载 作者:行者123 更新时间:2023-11-29 00:57:22 25 4
gpt4 key购买 nike

在我的 android 项目中启用 D8 后,我开始看到这些警告:

/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.<clinit>()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.cache.Striped64.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.hash.LittleEndianByteArray$UnsafeByteArray.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.<clinit>()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.cache.Striped64.getUnsafe()`
/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar: D8: Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.hash.LittleEndianByteArray$UnsafeByteArray.getUnsafe()`

.

项目构建成功,但在运行时,我看到这些错误日志,因此,应用程序功能受到影响。

 java.lang.AbstractMethodError: abstract method "java.lang.Object com.google.common.base.e.a(java.lang.Object)"
at com.google.common.e.a.i$c.a(SourceFile:1464)
at com.google.common.e.a.i$c.a(SourceFile:1453)
at com.google.common.e.a.i$a.run(SourceFile:1408)
at com.google.common.e.a.l$a.execute(SourceFile:456)
at com.google.common.e.a.i$f.a(SourceFile:153)
at com.google.common.e.a.i.a(SourceFile:1234)

搜索了一段时间后,我没能找到任何有用的东西。请帮忙。

是的,如果禁用 D8 并且其他一切都保持不变,我不会在运行时遇到此错误。

最佳答案

你需要保持sun.misc.Unsafe:

-keep class sun.misc.Unsafe { *; }
-dontnote sun.misc.Unsafe

或者,带有includedescriptorclasses 的规则应该保持动态:

-keep,includedescriptorclasses class com.google.common.**

一般来说:

  • 添加开关-verbose对编写ProGuard配置规则很有帮助。

  • 添加开关-dontoptimize可用于禁用所有优化,以供测试。

刚找到this :

R8 now understands proguard specs in META-INF/proguard.

但除非已添加,否则必须添加自定义规则 - 而不是使用消费者规则。

关于android - D8 : Type `sun.misc.Unsafe` was not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53665135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com