4
votes

So i have a bare react-native application wherein i am using expo modules.

I am using the expo location module and getting the following error.

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:361: error: cannot find symbol
        new Permissions.PermissionsRequestListener() {
                    ^
symbol:   class PermissionsRequestListener
location: interface Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:502: error: cannot find symbol
        mPermissions.getPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                    ^
symbol:   method getPermission(String)
location: variable mPermissions of type Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:503: error: cannot find symbol
            && mPermissions.getPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
                        ^
symbol:   method getPermission(String)
location: variable mPermissions of type Permissions
Note: /home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':expo-location:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 16s

    at checkExecSyncError (child_process.js:607:13)
    at execFileSync (child_process.js:627:13)
    at runOnAllDevices (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
    at buildAndRun (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
    at then.result (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7);

So my best guess is there is an error while importing stuff from permission module.

So i have these lines in expo-permissions app level build.gradle file.

compileOnly('com.facebook.react:react-native:+') {
    exclude group: 'com.android.support'
}

I am also using jettifier, i am guessing there is some issue with respect to transpiling code to android x.

I changed this

compileOnly('com.facebook.react:react-native:+') {
    exclude group: 'com.android.support'
}

to

implementation 'com.facebook.react:react-native:+'

and everything works fine.

I would like to know exactly what is happening and if this deserves a pull request.

Any help on the same would be highly appreciated thanks.

1
when try this (adding the above tot android/app/build.grade I get the following when outside of android {}: > compileSdkVersion is not specified. and when inside: > Could not find method compileOnly() for arguments [com.facebook.react:react-native:+, build_ea9v2sqboq1zxibbagnrw371$_run_closure1$_closure5@43a3aee1] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension. - Macilias
Hi macilias I did post an issue in expo where the told me I had a different versio for expo uniModule and expo location which was the cause for this error.... thanks anyway - Amol Gupta
which version was it, can you share some more info? thanks - Macilias
I don't really remember the issue was quite some time back.... - Amol Gupta

1 Answers

-1
votes

ok, in my case I needed to raise the following versions from android/build.grade:

buildscript {
    ext {
        buildToolsVersion = "28.0.3" -> "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 28 -> 29
        targetSdkVersion = 28 -> 29
    }