【问题标题】:Android dependency 'com.airbnb.android:lottie' has different version for the compile (2.5.5)and runtime (2.5.6) classpathAndroid 依赖 'com.airbnb.android:lottie' 的编译(2.5.5)和运行时(2.5.6)类路径有不同的版本
【发布时间】:2019-02-26 09:46:32
【问题描述】:

当我尝试运行我的 react native 应用程序时收到此错误我手动将版本更改为 2.5.6 但我在下面遇到了不同的错误: [循环参考:com.android.tools.r8.ApiLevelException: Invoke-customs ae 仅支持从 Android O (--min-api 26) 开始]

失败

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

  • 出了什么问题: 任务 ':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'
}

【问题讨论】:

    标签: react-native


    【解决方案1】:

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

    查看lottie-react-native repo 中的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)]

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

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

    【讨论】:

    • 我已将其删除,现在出现此错误。任务 ':app:transformClassesWithDexBuilderForDebug' 执行失败。 > com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: 无法处理 C:\Users\Dell\.gradle\caches\transforms- 1\files-1.1\lottie-2.5.6.aar\add5db5cebf38e2804a0cb8​​57e5cf364\jars\classes.jar
    • 不要在cmets中发布大量代码,无法阅读。如果您启用了即时运行,请尝试禁用它。 Android Studio -> File -> Settings -> Build, Execution, Deployment -> Instant Run -> Disable
    • 是的,禁用它。
    • 还有其他解决办法吗?
    • 您在package.json 中使用的是哪个版本的lottie-react-native
    猜你喜欢
    • 1970-01-01
    • 2018-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-20
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多