Android依赖项'com.airbnb.android:lottie'对于编译(2.5.5)和运行时(2.5.6)类路径具有不同的版本

时间:2019-02-26 09:46:32

标签: react-native

当我尝试运行我的React Native应用程序时遇到此错误,我将版本手动更改为2.5.6,但是下面出现了其他错误:         [循环参考:com.android.tools.r8.ApiLevelException:仅从Android O(--min-api 26)开始支持调用自定义ae]

失败

失败:构建失败,并出现异常。

  • 出了什么问题: 任务':app:transformClassesWithDexBuilderForDebug'的执行失败。

      

    com.android.build.api.transform.TransformException:com.android.builder.dexing.DexrchiveBuilderException:com.android.builder.dexing.DexArchiveBuilderException:难以处理C:\ Users \ Dell.gradle \ caches \ transforms -1 \ files-1.1 \ lottie-2.5.6.aar \ adddb5cebf38e2804a0cb8​​57e5cf364 \ jars \ classes.jar

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug optin运行以获取更多日志输出。使用--scan运行以获取完整的见解。

  • https://help.gradle.org

  • 获得更多帮助

21秒内失败 147个可执行任务:已执行1个,最新146个 无法在设备上安装该应用,请阅读上面的错误以获取详细信息。 确保您正在运行Android模拟器或已连接设备,并且 设置您的Android开发环境: https://facebook.github.io/react-native/docs/getting-started.html

这是我的依赖

dependencies {


  compile project(':lottie-react-native')
  implementation project(':lottie-react-native')
  implementation('com.airbnb.android:lottie:2.5.5') {
  exclude group: 'com.android.support'
}

1 个答案:

答案 0 :(得分:0)

您似乎已在依赖项中添加了一个额外的依赖项。

lottie-react-native仓库中查看example project时,他们只会添加compile project(':lottie-react-native')

这是他们对示例项目的依赖。 (请注意,compile应该替换为implementation

dependencies {
    compile project(':lottie-react-native')
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:support-annotations:26.1.0'
    compile "com.facebook.react:react-native:+"  // From node_modules
}

请注意,他们没有

implementation('com.airbnb.android:lottie:2.5.5') {
  exclude group: 'com.android.support'
}

在我从未使用过Lottie的任何项目中,

implementation('com.airbnb.android:lottie:2.5.5')

如果删除该行,则应该解决问题。


仅从Android O(--min-api 26)开始支持Invoke-customs

此错误是由Lottie依赖项需要Java 8字节码引起的。因此,要使其正常工作,我们需要在app/build.gradle中启用退格功能。因此,我们需要告诉它使用Java8。我们通过更新android部分来做到这一点。

android {
  defaultConfig {
    ...
  }
  // add the following
  compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
  }
}