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

18.4k Views Asked by At

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.

6

There are 6 best solutions below

0
On

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

3
On

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
0
On

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",
}
4
On

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
1
On

You might have installed a newer version of expo-camera. I've had the same issue with the expo-clipboard package.

My project was using expo@44 and I followed the official docs and ran npm install expo-clipboard which installed the latest version, which is compatible with the latest expo version at this time is expo@46.

The simple fix is to use the right version based on your expo version.

  1. Find your expo version in your package.json. Mine was "expo": "~44.0.0",
  2. Go to https://github.com/expo/expo/tree/sdk-{version}/packages. (Mine was https://github.com/expo/expo/tree/sdk-44/packages).
  3. Find the package you want to use like expo-clipboard and go to its package.json file to check the version Ex. https://github.com/expo/expo/blob/sdk-44/packages/expo-clipboard/package.json#L3
  4. Install that specific version npm install [email protected]

Hope it helps!

0
On

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.