android 第一次创建时无法构建裸Expo应用程序(Expo SDK 42)

jchrr9hc  于 2023-04-18  发布在  Android
关注(0)|答案(4)|浏览(169)

我创建了一个react native应用

expo init AwesomeProject

我选择了裸工作流
一旦我尝试使用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

这是我运行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

/android/gradle/wrapper/gradle-wrapper.属性:

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

/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' }
    }
}

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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

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

uajslkp6

uajslkp61#

这是一个错误当运行在windows.卸载react-native-unimodules和重新安装它得到最新版本的@unimodules/react-native-adapter(6.3.3)

hs1ihplo

hs1ihplo2#

我有一个类似的问题后安装expo-location插件,在我的情况下安装expo-modules-autolinking的错误消失,也许你想试试🥷

xiozqbni

xiozqbni3#

expo-modules-autolinking是为esnext构建的。这就是为什么在index.js文件中无法识别??运算符。
您可以更新到节点v16
或者通过在expo-modules-autolinking模块的tsconfig.json中更改target来为es 5重新编译它。然后通过执行cd node_modules/expo-modules-autolinking,我用npx tsc命令重新编译它。

esbemjvw

esbemjvw4#

您需要设置Node v16在linux中,Android studio使用/usr/local/bin/node下的Node。
如果在node --version返回v16.14.0的情况下仍然出现此问题,则需要更新符号链接

sudo ln -s $(which node) /usr/local/bin/node

相关问题