【问题标题】:Missing class: com.fasterxml.jackson.core.type.TypeReference. R8:Warning缺少类:com.fasterxml.jackson.core.type.TypeReference。 R8:警告
【发布时间】:2019-08-26 06:43:29
【问题描述】:

在我将 Android Studio 更新到 3.5 后,每当我构建我的项目时都会面临以下警告。

缺少类:com.fasterxml.jackson.core.type.TypeReference

我的项目正在使用 AndroidX。这是我的 build.gradle(app) 的要点 https://gist.github.com/Arkar009/4ae5a05ff3435636bc605fee1fbdb050 。谁能知道为什么会发生此错误或解决此错误的替代方法?提前致谢。

【问题讨论】:

  • 从你的截图来看,这似乎只是一个警告。能否添加应用程序 gradle 文件以便我们可以看到导入语句?
  • @tomerpacific,我已经更新了这个问题。谢谢。
  • 我在您所附的要点中没有看到杰克逊的任何进口。你有它作为本地罐子吗?
  • @tomerpacific,我只使用了 jcenter 库,除了打印库之一。

标签: android-studio jackson android-r8


【解决方案1】:

如果您非常确定如果您稍后在项目中包含 Jackson,您会记住这一行,那么这就是诀窍(将其添加到项目的 proguard-project.[txt|pro] 文件中):

-dontwarn com.fasterxml.jackson.core.type.TypeReference

该类以某种方式包含在 R8 中的缺失类集中(我在 R8 的代码中没有走那么远),但是如果您在“不要警告”的模式列表中获得该类,则可以跳过警告" 规则(参见 com/android/tools/r8/R8.java):

  List<ProguardConfigurationRule> synthesizedProguardRules = new ArrayList<>();
  timing.begin("Strip unused code");
  Set<DexType> classesToRetainInnerClassAttributeFor = null;
  try {
    Set<DexType> missingClasses = appView.appInfo().getMissingClasses();
    missingClasses = filterMissingClasses(
        missingClasses, options.getProguardConfiguration().getDontWarnPatterns());
    if (!missingClasses.isEmpty()) {
      missingClasses.forEach(
          clazz -> {
            options.reporter.warning(
                new StringDiagnostic("Missing class: " + clazz.toSourceString()));
          });

TBH,我也被这个警告困扰到进入 R8,希望它有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-01
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2020-12-04
    • 2013-05-16
    • 1970-01-01
    相关资源
    最近更新 更多