由于 hermes-debug.aar 引用,gradle bundleDebugAar 步骤失败

标签 gradle react-native react-native-hermes

我正在维护一个 brownfield react-native 应用程序,并将 react-native 版本从 0.59.9 迁移到 0.63.4。我完成了更改日志和升级助手中定义的步骤,并且可以在模拟器上运行该应用程序,但是当我尝试构建它时,我在 bundleDebugAar 步骤中遇到此错误:

> Direct local .aar file dependencies are not supported when building an 
AAR. The resulting AAR would be broken because the classes and Android 
resources from any local .aar file dependencies would not be packaged in 
the resulting AAR. Previous versions of the Android Gradle Plugin produce 
broken AARs in this case too (despite not throwing this error). The 
following direct local .aar file dependencies of the :myapp-react-
integration project caused this error: /Users/.../node_modules/hermes-
engine/android/hermes-release.aar

渐变版本:

const val BUILD_TOOLS_VERSION = "30.0.1"
const val GRADLE_VERSION = "4.0.1"

这是我的 build.gradle.kts:

plugins {
    id(BuildPlugins.androidLibrary)
    id(BuildPlugins.kotlinAndroid)
    id(BuildPlugins.kotlinAndroidExtensions)
    id(BuildPlugins.kotlinKapt)
    id(BuildPlugins.junit)
}

android{
    androidExtensions {
        isExperimental = true
    }
}

val react by extra {
    mapOf(
        "enableHermes" to true
    )
}

dependencies {

    // Dependencies for local unit tests
    // JUnit and Mockito
    junit5()
    mockito()
    testImplementation(TestLibraries.JUNIT4)

    api(Libraries.REACT_NATIVE)
    implementation("com.facebook.soloader:soloader:0.9.0")
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")


    implementation(Libraries.Tracking.SNOWPLOW)
    implementation(project(Libraries.Tracking.BRAZE_REACT_NATIVE))

    rx()
    dagger()
    firebase()
    implementation(Libraries.gson)
    implementation(Libraries.Timber)
    implementation(Libraries.AndroidX.PREFERENCE)
    implementation(TestLibraries.Espresso.IDLING)
    androidTestRuntimeOnly(TestLibraries.Junit5.RUNNER)

    /********************************************/
    /*                 REACT                    */
    /** ******************************************/
    val hermesPath = "$rootDir/node_modules/hermes-engine/android/"
    debugImplementation(files(hermesPath + "hermes-debug.aar"))
    releaseImplementation(files(hermesPath + "hermes-release.aar"))
}

如果有人能提供帮助,我会很高兴。

谢谢。

最佳答案

Hermes 在最近版本的 react-native 中移动,而不是:

val hermesPath = "$rootDir/node_modules/hermes-engine/android/"
debugImplementation(files(hermesPath + "hermes-debug.aar"))
releaseImplementation(files(hermesPath + "hermes-release.aar"))

implementation("com.facebook.react:hermes-engine:+") { // From node_modules
  exclude group:'com.facebook.fbjni'
}

关于由于 hermes-debug.aar 引用,gradle bundleDebugAar 步骤失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66168353/

相关文章:

react-native - Jest TransformIgnorePatterns 所有 node_modules 用于 React-Native Preset

react-native - Flipper:Flipper Hermes 调试器不显示

gradle - Sonar 违规的 Gradle 构建失败

android - 如何使用全局本地 gradle 安装而不是每次都下载压缩包装?

react-native - 如何处理 native react 中的多个资源?

javascript - 特定 React Native 事件的流类型?

javascript - React Native iOS - Hermes 在 Podfile 中启用,但在应用程序中未启用

React Native 项目的 xcode 存档 "Library not found for -lReact-hermes"

gradle - 如何诊断/解决gradle构建未运行依赖项任务的问题?

java - 在 Gradle 中禁用所有 JavaDoc