首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从ThreeTenABP向java.time迁移时的综合警告

从ThreeTenABP向java.time迁移时的综合警告
EN

Stack Overflow用户
提问于 2020-10-29 15:58:05
回答 1查看 322关注 0票数 3

最近,我们启用了Java8去加林,以便将https://github.com/JakeWharton/ThreeTenABP移植到java.time

build.gradle

代码语言:javascript
复制
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 29
    multiDexEnabled true

compileOptions {
    // Flag to enable support for the new language APIs
    coreLibraryDesugaringEnabled true

    targetCompatibility 1.8
    sourceCompatibility 1.8
}

dependencies {    
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'

没有汇编问题。然而,当我们试图运行应用程序仿真器API 18,我们将得到以下警告。

代码语言:javascript
复制
> Transform artifact desugar_jdk_libs_configuration-1.0.10.jar (com.android.tools:desugar_jdk_libs_configuration:1.0.10) with L8DexDesugarLibTransform
Warning: Type `j$.util.OptionalDouble` was not found, it is required for default or static interface methods desugaring of `j$.util.OptionalDouble j$.util.OptionalConversions.convert(java.util.OptionalDouble)`
Warning: Type `j$.util.OptionalLong` was not found, it is required for default or static interface methods desugaring of `j$.util.OptionalLong j$.util.OptionalConversions.convert(java.util.OptionalLong)`
Warning: Type `j$.util.OptionalInt` was not found, it is required for default or static interface methods desugaring of `j$.util.OptionalInt j$.util.OptionalConversions.convert(java.util.OptionalInt)`
Warning: Type `j$.time.ZonedDateTime` was not found, it is required for default or static interface methods desugaring of `j$.time.ZonedDateTime j$.time.TimeConversions.convert(java.time.ZonedDateTime)`
Warning: Type `j$.time.ZoneId` was not found, it is required for default or static interface methods desugaring of `j$.time.ZoneId j$.time.TimeConversions.convert(java.time.ZoneId)`
Warning: Type `j$.time.MonthDay` was not found, it is required for default or static interface methods desugaring of `j$.time.MonthDay j$.time.TimeConversions.convert(java.time.MonthDay)`
Warning: Type `j$.time.Instant` was not found, it is required for default or static interface methods desugaring of `j$.time.Instant j$.time.TimeConversions.convert(java.time.Instant)`
Warning: Type `j$.time.LocalDate` was not found, it is required for default or static interface methods desugaring of `j$.time.LocalDate j$.time.TimeConversions.convert(java.time.LocalDate)`
Warning: Type `j$.time.Duration` was not found, it is required for default or static interface methods desugaring of `j$.time.Duration j$.time.TimeConversions.convert(java.time.Duration)`
Warning: Type `j$.util.DesugarGregorianCalendar` was not found, it is required for default or static interface methods desugaring of `j$.time.ZonedDateTime j$.$r8$backportedMethods$utility$GregorianCalendar$toZonedDateTime$dispatchHolder.toZonedDateTime(java.util.GregorianCalendar)`
Warning: Type `j$.util.DesugarDate` was not found, it is required for default or static interface methods desugaring of `j$.time.Instant j$.$r8$backportedMethods$utility$Date$toInstant$dispatchHolder.toInstant(java.util.Date)`

> Transform artifact desugar_jdk_libs-1.0.10.jar (com.android.tools:desugar_jdk_libs:1.0.10) with L8DexDesugarLibTransform
Warning in synthesized for lambda desugaring:
  Type `j$.$r8$wrapper$java$util$function$ToDoubleFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.util.Comparator java.time.chrono.-$$Lambda$AbstractChronology$5b0W7uLeaWkn0HLPDKwPXzJ7HPo.thenComparingDouble($-vivified-$.java.util.function.ToDoubleFunction)`
Warning in synthesized for lambda desugaring:
  Type `j$.$r8$wrapper$java$util$function$Function$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.util.Comparator java.time.chrono.-$$Lambda$AbstractChronology$5b0W7uLeaWkn0HLPDKwPXzJ7HPo.thenComparing($-vivified-$.java.util.function.Function)`
Warning in synthesized for lambda desugaring:
  Type `j$.$r8$wrapper$java$util$function$ToIntFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.util.Comparator java.time.chrono.-$$Lambda$AbstractChronology$5b0W7uLeaWkn0HLPDKwPXzJ7HPo.thenComparingInt($-vivified-$.java.util.function.ToIntFunction)`
Warning in synthesized for lambda desugaring:
  Type `j$.$r8$wrapper$java$util$function$ToLongFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.util.Comparator java.time.chrono.-$$Lambda$AbstractChronology$5b0W7uLeaWkn0HLPDKwPXzJ7HPo.thenComparingLong($-vivified-$.java.util.function.ToLongFunction)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/stream/Collectors$Partition$1.class:
  Type `j$.$r8$wrapper$java$util$Spliterator$-WRP` was not found, it is required for default or static interface methods desugaring of `$-vivified-$.java.util.Spliterator java.util.stream.Collectors$Partition$1.spliterator()`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/stream/Collectors$Partition$1.class:
  Type `j$.$r8$wrapper$java$util$function$Consumer$-V-WRP` was not found, it is required for default or static interface methods desugaring of `void java.util.stream.Collectors$Partition$1.forEach($-vivified-$.java.util.function.Consumer)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/stream/Collectors$Partition$1.class:
  Type `j$.$r8$wrapper$java$util$stream$Stream$-WRP` was not found, it is required for default or static interface methods desugaring of `$-vivified-$.java.util.stream.Stream java.util.stream.Collectors$Partition$1.parallelStream()`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/stream/Collectors$Partition$1.class:
  Type `j$.$r8$wrapper$java$util$function$Predicate$-V-WRP` was not found, it is required for default or static interface methods desugaring of `boolean java.util.stream.Collectors$Partition$1.removeIf($-vivified-$.java.util.function.Predicate)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/stream/Collectors$Partition$1.class:
  Type `j$.$r8$wrapper$java$util$function$IntFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `java.lang.Object[] java.util.stream.Collectors$Partition$1.toArray($-vivified-$.java.util.function.IntFunction)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/DesugarCollections$SynchronizedMap.class:
  Type `j$.$r8$wrapper$java$util$function$BiFunction$-V-WRP` was not found, it is required for default or static interface methods desugaring of `void java.util.DesugarCollections$SynchronizedMap.replaceAll($-vivified-$.java.util.function.BiFunction)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/DesugarCollections$SynchronizedMap.class:
  Type `j$.$r8$wrapper$java$util$function$BiConsumer$-V-WRP` was not found, it is required for default or static interface methods desugaring of `void java.util.DesugarCollections$SynchronizedMap.forEach($-vivified-$.java.util.function.BiConsumer)`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/concurrent/ThreadLocalRandom.class:
  Type `j$.$r8$wrapper$java$util$stream$IntStream$-WRP` was not found, it is required for default or static interface methods desugaring of `$-vivified-$.java.util.stream.IntStream java.util.concurrent.ThreadLocalRandom.ints()`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/concurrent/ThreadLocalRandom.class:
  Type `j$.$r8$wrapper$java$util$stream$LongStream$-WRP` was not found, it is required for default or static interface methods desugaring of `$-vivified-$.java.util.stream.LongStream java.util.concurrent.ThreadLocalRandom.longs()`
Warning in C:\Users\yccheok\.gradle\caches\modules-2\files-2.1\com.android.tools\desugar_jdk_libs\1.0.10\61bd346a9d026c92028eb8c8c29e09368b22633c\desugar_jdk_libs-1.0.10.jar:java/util/concurrent/ThreadLocalRandom.class:
  Type `j$.$r8$wrapper$java$util$stream$DoubleStream$-WRP` was not found, it is required for default or static interface methods desugaring of `$-vivified-$.java.util.stream.DoubleStream java.util.concurrent.ThreadLocalRandom.doubles(long)`
Warning: Type `j$.util.OptionalConversions` was not found, it is required for default or static interface methods desugaring of `java.util.OptionalLong j$.$r8$wrapper$java$util$stream$LongStream$-WRP.reduce(java.util.function.LongBinaryOperator)`
Warning: Type `j$.util.LongSummaryStatisticsConversions` was not found, it is required for default or static interface methods desugaring of `java.util.LongSummaryStatistics j$.$r8$wrapper$java$util$stream$LongStream$-WRP.summaryStatistics()`
Warning: Type `j$.util.DoubleSummaryStatisticsConversions` was not found, it is required for default or static interface methods desugaring of `java.util.DoubleSummaryStatistics j$.$r8$wrapper$java$util$stream$DoubleStream$-WRP.summaryStatistics()`

> Task :app:processDebugResources

> Transform artifact desugar_jdk_libs-1.0.10.jar (com.android.tools:desugar_jdk_libs:1.0.10) with L8DexDesugarLibTransform
Warning: Type `j$.util.IntSummaryStatisticsConversions` was not found, it is required for default or static interface methods desugaring of `java.util.IntSummaryStatistics j$.$r8$wrapper$java$util$stream$IntStream$-WRP.summaryStatistics()`

我们将得到以下运行时错误。

代码语言:javascript
复制
10-29 15:48:43.167 3959-3959/? E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: androidx.arch.core.internal.SafeIterableMap
        at androidx.lifecycle.LiveData.<init>(LiveData.java:66)
        at androidx.lifecycle.MutableLiveData.<init>(MutableLiveData.java:40)
        at com.yocto.wenote.SingleLiveEvent.<init>(SingleLiveEvent.java:38)
        at com.yocto.wenote.WeNoteApplication.<init>(WeNoteApplication.java:94)
        at java.lang.Class.newInstanceImpl(Native Method)

WeNoteApplication.java:94

代码语言:javascript
复制
private final SingleLiveEvent<Boolean> onResumePasswordPromptSingleLiveEvent = new SingleLiveEvent<>();

这让我很困惑,对我来说也没有任何意义。因此,我们不确定Java8的去向如何影响SingleLiveEvent (从MutableLiveData继承)。

你知道我们怎样才能消除这一切吗?

EN

回答 1

Stack Overflow用户

发布于 2021-12-31 15:03:00

Java8需要启用MultiDex。从API 21开始,默认情况下支持MultiDex,而不需要MultiDex支持库。

要正确支持API < 21上的MultiDex,需要更新Application类:

代码语言:javascript
复制
override fun attachBaseContext(base: Context?) {
    super.attachBaseContext(base)
    MultiDex.install(this)
}

如果没有,在这些设备上将找不到未位于第一个dex文件中的类。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64594747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档