Execution failed for task ':expo-permissions:compileDebugKotlin'

Viewed 11797

I am working on a React Native app where I included some expo libraries (bare workflow). I had successfully used expo-location, but now after I installed also expo-camera, the app won't build anymore with npm run android, did not try yet on ios.

It will crash at :expo-permissions:compileDebugKotlin step.

I did find the problem on another forum, they were saying to update the buildToolsVersion from build.gradle to 29.0.2 but it already was on 29.0.2. Then I updated react-native-unimodules which is required to use expo libraries and contains expo-permissions. It didn't work. Right now, my current versions of libs are:

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

"expo-permissions": "~10.0.0"

"expo-camera": "^9.1.1"

Do you have any ideas? Did someone met this problem also?

Thanks

A more elaborate stacktrace is this:

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.

5 Answers

You may not want to take the version being referenced by others online, but, instead take the version of what you have installed locally, which would vary depending on when you last updated your Android SDK.

On Windows you can look up your SDK version (tools version):

dir %ANDROID_SDK_ROOT%\build-tools

Probably *nix systems will have a similar SDK path (did not check):

ls -al $ANDROID_SDK_ROOT\build-tools

You would probably want to update this to match the SDK corresponding to the Platform of the device you are targeting. In my case I am targeting Platform 29, and in my /build-tools/ directory I find a "/29.0.3/" directory (among others).. So, I edited my build.gradle:

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

.. after my edit I was able to successfully build and deploy to my Android device again.

You may need to update your SDK, as well. I experienced this on a project which was building just fine for over a year, then I updated expo-gl-cpp package (and a few others) and immediately had the same problem/error you are having. I had to update my SDK for Platform 29 and then modify my build.gradle settings before I was up and running again. I use Android Studio to manage my SDKs, it's all point-and-click, easy to use. I don't use it for anything else, never had the need.

HTH!

I have solved this issue by downgrading react-native-unimodules from version 0.13.2 to 0.12.0

I solved this by downgrading react-native-unimodules from version 0.13.2 to 0.12.0, I think the problem is that the new version of unimodules requires upgrading your android build tools so the right thing is not downgrading the unimodules but upgrading your build tools from 28.0.0 to 29.0.3 like this:

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

I got mine working by reducing my expo version from 43.0.0 to 40.0.0 and setting 'sdkVersion': "38.0.0". It appears the versions didn't match with each other or with some other expo dependencies.

in app.json:

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

...and in 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",
}

I'm facing the same issue when I rebuild my project or try to run on a Device.

I install expo-permissions by using expo install expo-permissions on my expo project and then go to Android Studio and Sync my project after that I clean my project which you can find on build/Clean Project after this I install Kotlin extension on Android Studio after that again clean project and then rebuild Project (build/Rebuild Project).

These Steps resolve my issue.

Related