Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expo permissions build error [SDK39] #10283

Closed
damianrekosz opened this issue Sep 22, 2020 · 18 comments
Closed

Expo permissions build error [SDK39] #10283

damianrekosz opened this issue Sep 22, 2020 · 18 comments

Comments

@damianrekosz
Copy link

I just updated SDK version from 38 to 39 and I can't start my project. I'm getting this error:

Task :expo-permissions:compileDebugKotlin FAILED
e: node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\requesters\LocationRequester.kt: (20, 54): Unresolved reference: Q
e: node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\requesters\LocationRequester.kt: (22, 29): Unresolved reference: ACCESS_BACKGROUND_LOCATION
e: node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\requesters\LocationRequester.kt: (57, 58): Unresolved reference: Q
e: node_modules\expo-permissions\android\src\main\java\expo\modules\permissions\requesters\LocationRequester.kt: (58, 91): Unresolved reference: ACCESS_BACKGROUND_LOCATION

I tried gradlew clean and npx react-native --reset-cache but nothing helps.

@damianrekosz damianrekosz changed the title Build error [SDK39] Expo permissions build error [SDK39] Sep 22, 2020
@byCedric
Copy link
Member

Hi @damianrekosz, it looks like you are using slightly outdated build tools to build your app. If you are running a bare project, you have to make sure your build tools are compatible with Android Q, because of the Google restriction to build for SDK 29 and up. You can find more info about the build tools here.

You should be able to upgrade by setting buildToolsVersion = "29.0.2" (or higher).

Hope this helps!

@damianrekosz
Copy link
Author

Yeah, i had outdated build tools. Now everything works perfectly.

@mrcflorian
Copy link

I was getting the same error, with buildToolsVersion = "29.0.2". Pinning the expo-permissions version down to

"expo-permissions": "9.1.0",

fixed the issue.

@jlcouto
Copy link

jlcouto commented Sep 23, 2020

I am currently stuck with this. Updating build tools to lastest version and trying to compile to Nexus 5 API Level 29 still resulted in the same error. I am now trying to use expo-permission v 9.1.0, but when building with gradle, react-native-unimodule seems to find it deprecated and force its update:

"Found some duplicated unimodule packages. Installed the ones with the highest version number.
Make sure following dependencies of your project are resolving to one specific version:
expo-permissions, expo-file-system"

So the Android project receives the new code and give the same error all over again. I am currently trying to clean all build files or find how to not force this update, but up to now, no success.

Does anyone have any recommendation?

@jlcouto
Copy link

jlcouto commented Sep 23, 2020

I finally solved it: first I was not using expo sdk 39 as I initially thought (it showed as version 39 at package.json, but I had not upgraded it with "expo upgrade"). But this alone would not solve the problem. I finally made it work by deleting both iOS and Android folders and ejecting my project again. Then I had some other package problems, but after fighting one by one, I can finally run my app on both iOS and Android devices.

@GrabbenD
Copy link

I was able to resolve this issue and I'll leave the steps here If anyone runs into this issue in the future in a ejected/bare React Native project:

  1. Make sure your dependencies are pinned and up to date (naturally you'll need to ensure compatibility between package versions in your environment. In a lot of cases using the latest releases should be enough but this action might break your project if you don't carefully investigate if there's any breaking changes. With yarn it's as simple as: yarn upgrade --latest --exact)
  2. Make sure your Gradle Wrapper is up to date ./gradlew wrapper --gradle-version=VERSIONHERE, I tend to check react-native's template for Android (gradle-wrapper.properties) as a reference.
  3. Check your dependencies in build.gradle. I found Expo's version extremely helpful and the one provided in react-native too. I used Expo's ext and dependencies configurations under buildscript (however, make sure to remove whatever doesn't match your project's needs).

@eyalyoli
Copy link

I also got the same error after the upgrade, and for me, I need to upgrade the minimal SDK 28->29 in addition to buildToolsVersion = "29.0.2"

@JackNgWeiMing
Copy link

JackNgWeiMing commented Jan 25, 2021

had same issue , but using react-native init project with react-native-unimodules@0.12.0

Error:

> Task :expo-permissions:compileDebugKotlin FAILED

My fix, under androd/build.gragle

buildscript {
    ext {
        buildToolsVersion = "28.0.2" //  (optional  to upgrade ???)
        minSdkVersion = 21 // react-native-unimodule@0.12.0 require minSdkVersion - 21 
        compileSdkVersion = 29 // <--upgrade this to 29
        targetSdkVersion = 28
    }
}

@listiani13
Copy link

listiani13 commented Feb 25, 2021

Had the same issue, using ejected expo 40 in monorepo (with yarn workspaces)

Error:

/path/to/node_modules/expo/modules/permissions/PermissionsService.kt: (16, 40): Unresolved reference: PermissionAwareActivity

Was caused by provided node_modules path in android/build.gradle
Since we're hoisting the packages into the root, we need to customize paths to node_modules. The folder structure looks like this:

node_modules
packages
├── @types
├── app
│   ├── android
│   ├── ios
└── another_app
    └── src

Need to do this: https://docs.expo.io/bare/installing-unimodules/ (see using custom node_modules path)

And then resolve the path this way in android/build.gradle

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../../../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../../../node_modules/jsc-android/dist")
        }

        google()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}

Hope this helps!

@archcorsair
Copy link

I've ejected from managed flow into a bare flow, if I bump my gradle version to 4.1.0 or above I get the expo-permssions error posted above
image

Here is my buildscript section in android/build.gradle

buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"

I also tested with com.android.tools.build:gradle:4.1.3 with the same issue.

@hyochan
Copy link
Contributor

hyochan commented Apr 16, 2021

Had the same error after upgrading to expo sdk 41. Below is the only fixes.

        buildToolsVersion = "30.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        ndkVersion = "20.1.5948944"

@archcorsair
Copy link

For those that use the ejected, bare workflow. I found a workaround that solved my issue. This only worked for me because I do not use expo-permissions in my repo.

android/app/build.gradle:
Replace:

addUnimodulesDependencies()

with

addUnimodulesDependencies([exclude: ['expo-permissions']])

@slavikdenis
Copy link

@archcorsair your comment helped, thanks.

Also, don't forget to make the same changes for iOS in Podfile:

Replace:

use_unimodules!

with

use_unimodules!(exclude: ['expo-permissions'])

@endronk
Copy link

endronk commented May 5, 2021

For those that use the ejected, bare workflow. I found a workaround that solved my issue. This only worked for me because I do not use expo-permissions in my repo.

android/app/build.gradle:
Replace:

addUnimodulesDependencies()

with

addUnimodulesDependencies([exclude: ['expo-permissions']])

In my case, also need to remove or comment out the following on MainApplication.java:

import expo.modules.permissions.PermissionsPackage;

@hengsok
Copy link

hengsok commented May 10, 2021

Just to add on to @hyochan answer, some of us may specify the buildToolsVersion for subprojects separately too in build.gradle file. So make sure also update the buildToolsVersion there as well.

You really do not need to exclude expo-permissions like above because this is related to the build tool version and expo-permissions is actually needed for some expo packages to work.

subprojects { subproject ->
    afterEvaluate {
        if ((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion 30

               buildToolsVersion "30.0.3"<<< change here too

                defaultConfig {
                    targetSdkVersion 30
                }
                variantFilter { variant ->
                    def names = variant.flavors*.name
                    if (names.contains("reactNative59")) {
                        setIgnore(true)
                    }
                }
            }
        }
    }
}

@rodrigorm
Copy link
Contributor

This solutions worked for me: #7901 (comment)

@MattLaszcz
Copy link

For the life of me I cannot solve this! I have tried everything here...would someone be willing to look at my LOG output and give me some assistance? I am sure its something simple I am overlooking.

@rodrigorm
Copy link
Contributor

For the life of me I cannot solve this! I have tried everything here...would someone be willing to look at my LOG output and give me some assistance? I am sure its something simple I am overlooking.

I can try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests