Bare Expo 应用程序在首次创建时无法构建(Expo SDK 42)

pra*_*001 5 android gradle reactjs react-native expo

我使用创建了一个反应本机应用程序

expo init AwesomeProject
Run Code Online (Sandbox Code Playgroud)

我选择了裸工作流程

一旦我尝试使用运行应用程序yarn android,构建就会崩溃。

这是错误:

 > Task :unimodules-react-native-adapter:compileDebugJavaWithJavac 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.8/userguide/command_line_interface.html#sec:command_line_warnings
284 actionable tasks: 284 executed
C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-modules-autolinking\build\index.js:14
        .option('-i, --ignore-paths <ignorePaths...>', 'Paths to ignore when looking up for modules.', (value, previous) => (previous ?? []).concat(value))
                                                                                                                                       ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at [eval]:1:1
    at Script.runInThisContext (vm.js:120:18)
    at Object.runInThisContext (vm.js:309:38)
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-application\android\src\main\java\expo\modules\application\ApplicationModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-updates\android\src\main\java\expo\modules\updates\UpdatesConfiguration.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-constants\android\src\main\java\expo\modules\constants\ConstantsService.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-file-system\android\src\main\java\expo\modules\filesystem\FileSystemModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-file-system\android\src\main\java\expo\modules\filesystem\FileSystemModule.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\@unimodules\react-native-adapter\android\src\main\java\org\unimodules\adapters\react\ModuleRegistryAdapter.java:26: error: cannot find symbol
    mModuleRegistryProvider = new ReactModuleRegistryProvider(new ExpoModulesPackageList().getPackageList(), null);
                                                                  ^
  symbol:   class ExpoModulesPackageList
  location: class ModuleRegistryAdapter
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':unimodules-react-native-adapter: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 5m 40s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
C:\Users\prana\Desktop\new-app\new-app\SphereV2\node_modules\expo-modules-autolinking\build\index.js:14
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

enter code here
Run Code Online (Sandbox Code Playgroud)

这是我运行后的环境react-native info

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 682.79 MB / 7.79 GB
  Binaries:
    Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK: Not Found
  IDEs:
    Android Studio: Version  4.1.0.0 AI-201.8743.12.41.6953283
    Visual Studio: Not Found
  Languages:
    Java: 11.0.2
    Python: 3.8.4
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1
    react-native: ~0.63.4 => 0.63.4
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
Run Code Online (Sandbox Code Playgroud)

/android/gradle/wrapper/gradle-wrapper.properites:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Run Code Online (Sandbox Code Playgroud)

/android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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' }
    }
}
Run Code Online (Sandbox Code Playgroud)

我系统上当前的Gradle 版本是 Gradle 6.8。我也尝试过使用 Gradle 7.0,在这种情况下,我最终收到一条错误消息:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这一问题??我正在运行最新的 expo SDK 版本 42。

Thi*_*ain 0

expo-modules-autolinking 是为 esnext 构建的。这就是??索引.js 文件中无法识别运算符的原因。

您可以更新到节点 v16

或者通过更改 expo-modules-autolinking 模块的 tsconfig.json 中的目标,为 es5 重新编译它。然后通过这样做cd node_modules/expo-modules-autolinking,我用npx tsc命令重新编译了它