【问题标题】:Execution failed for task ':expo-permissions:compileDebugKotlin'任务 ':expo-permissions:compileDebugKotlin' 执行失败
【发布时间】:2021-04-12 01:56:19
【问题描述】:

我正在开发一个 React Native 应用程序,其中包含一些 expo 库(裸工作流)。我已经成功使用了expo-location,但是现在在我也安装了expo-camera 之后,应用程序将不再使用npm run android 构建,还没有在ios 上尝试。

它将在:expo-permissions:compileDebugKotlin 步骤崩溃。

我确实在另一个论坛上发现了问题,他们说将buildToolsVersionbuild.gradle 更新为29.0.2,但它已经在29.0.2 上。然后我更新了react-native-unimodules,这是使用博览会库所必需的,并且包含博览会权限。它没有用。现在,我当前的库版本是:

"react-native-unimodules": "^0.12.0"

"expo-permissions": "~10.0.0"

"expo-camera": "^9.1.1"

你有什么想法吗?有人也遇到过这个问题吗?

谢谢

更详细的堆栈跟踪是这样的:

Task :expo-permissions:compileDebugKotlin FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings
153 actionable tasks: 4 executed, 149 up-to-date
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (16, 40): Unresolved reference: PermissionAwareActivity
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (170, 17): Unresolved reference: PermissionAwareActivity
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (236, 19): Unresolved reference: PermissionAwareActivity
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 62): Too many arguments for public final fun requestPermissions(@NonNull p
0: Array<(out) String!>, p1: Int): Unit defined in android.app.Activity
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 64): Cannot infer a type for this parameter. Please specify it explicitly.
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 77): Cannot infer a type for this parameter. Please specify it explicitly.
e: app\node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\PermissionsService.kt: (237, 97): Cannot infer a type for this parameter. Please specify it explicitly.

FAILURE: Build failed with an exception.

【问题讨论】:

    标签: android react-native expo expo-camera expo-permissions


    【解决方案1】:

    我通过将我的 expo 版本从 43.0.0 降低到 40.0.0 并设置“sdkVersion”:“38.0.0”来开始工作。似乎这些版本彼此不匹配,或者与其他一些博览会依赖项不匹配。

    app.json:

    {
      "name": "MyApp",
      "displayName": "MyApp",
          "expo": {
            "name": "MyApp",
            "slug": "myapp.app",
            "sdkVersion": "38.0.0"
          }
    }
    

    ...在 package.json 中:

    "dependencies" {
        "expo": "^40.0.0",
        "expo-file-system": "^9.3.0",
        "expo-linking": "~2.0.1",
        "expo-splash-screen": "~0.8.0",
        "expo-status-bar": "~1.0.3",
        "expo-updates": "^0.4.2",
    }
    

    【讨论】:

      【解决方案2】:

      我已经通过将 react-native-unimodules 从版本 0.13.2 降级到 0.12.0 解决了这个问题

      【讨论】:

        【解决方案3】:

        我通过将 react-native-unimodules 从版本 0.13.2 降级到 0.12.0 解决了这个问题, 我认为问题在于新版本的 unimodules 需要升级你的 android 构建工具,所以正确的做法不是降级 unimodules,而是将构建工具从 28.0.0 升级到 29.0.3,如下所示:

        buildscript {
            ext {
                buildToolsVersion = "29.0.3"
                minSdkVersion = 21
                compileSdkVersion = 29
                targetSdkVersion = 29
        

        【讨论】:

        • 问题:你的意思是降级 react-native-unimodules。它是否正确?用这个替换这个`“react-native-unimodules”:“^0.13.3”,`? "react-native-unimodules": "0.12.0",
        • A:删除了 v 1.13.2 的包并安装了旧版本 1.12.0
        • 没有 react-native-unimodules v 1.13.2。事实上,三是没有版本 1。我们仍然处于版本零。你说的是什么包? npmjs.com/package/react-native-unimodules。请具体说明包名或姓氏。
        • 0.12.0 我的错,编辑了答案
        【解决方案4】:

        您可能不想使用其他人在线引用的版本,而是使用您在本地安装的版本,这取决于您上次更新 Android SDK 的时间。

        在 Windows 上,您可以查看您的 SDK 版本(工具版本):

        dir %ANDROID_SDK_ROOT%\build-tools
        

        可能 *nix 系统会有类似的 SDK 路径(未检查):

        ls -al $ANDROID_SDK_ROOT\build-tools
        

        您可能需要更新它以匹配对应于您所定位设备的平台的 SDK。就我而言,我的目标是 Platform 29,在我的 /build-tools/ 目录中,我找到了一个“/29.0.3/”目录(等等)。所以,我编辑了我的build.gradle

        buildscript {
            ext {
                buildToolsVersion = "29.0.3"
                minSdkVersion = 29
                compileSdkVersion = 29
                targetSdkVersion = 29
        

        .. 编辑后,我能够再次成功构建并部署到我的 Android 设备。

        您可能还需要更新您的 SDK。我在一个构建了一年多的项目中遇到了这种情况,然后我更新了expo-gl-cpp 包(以及其他一些包),并立即遇到了同样的问题/错误。我必须为 Platform 29 更新我的 SDK,然后在我重新启动并运行之前修改我的 build.gradle 设置。我使用 Android Studio 来管理我的 SDK,它都是点击式的,易于使用。我不会用它来做任何其他事情,从来没有需要。

        HTH!

        【讨论】:

        • 我刚刚使用了另一个库,因为我没有足够的时间继续调查这个问题,但是感谢您的回答,也许它会对某人有所帮助(y)
        • 我是 react native 的初学者,在 node_modules 文件夹中到处都看到了 react native 视觉相机的版本 30,在我的 android/build.gradle 和 viola 中进行了更改,它运行完美
        • 我遇到了同样的错误,我无法解决它,我的构建脚本在下面吗?问题可能出在这里吗? buildscript { ext { buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 }
        猜你喜欢
        • 2022-11-06
        • 1970-01-01
        • 2022-11-07
        • 2023-01-05
        • 1970-01-01
        • 2022-10-23
        • 2022-08-18
        • 2020-03-07
        • 2023-03-15
        相关资源
        最近更新 更多