无法编译react-native-expo项目

时间:2019-12-02 18:11:03

标签: react-native expo

所以我有一个裸露的本机应用程序,其中我正在使用expo模块。

我正在使用expo定位模块并收到以下错误。

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);

所以我最好的猜测是从权限模块导入内容时出错。

所以我在expo-permissions应用级别build.gradle文件中有这些行。

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

我也在使用jettifier,我猜是在将代码转译到android x方面存在一些问题。

我更改了

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

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

一切正常。

我想确切地了解正在发生的事情,以及是否值得拉取请求。

在同一方面的任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

好的,就我而言,我需要从 android/build.grade 提升以下版本:

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