npx expo start # Works
npx expo prebuild # Works
npx expo run:android --device 1_Pixel_3a_ # Error
> Task :app:checkDebugDuplicateClasses FAILED
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* 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
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD FAILED in 26s
604 actionable tasks: 10 executed, 594 up-to-date
Error: /Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/android/gradlew exited with non-zero code: 1
Error: /Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/android/gradlew exited with non-zero code: 1
at ChildProcess.completionListener (/Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
at Object.onceWrapper (node:events:628:26)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
...
at Object.spawnAsync [as default] (/Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
at spawnGradleAsync (/Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46)
at Object.assembleAsync (/Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18)
at runAndroidAsync (/Users/joy/Dev/Projects/XXX/XXX-Mobile/mobile/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:31:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
我几乎猜不到原因是什么
npx expo run
要求获取世博会48 -> 50的更新,我拒绝了。
再次询问,所以我接受了。它没有正确更新(卡住了)。
ctrl + c
我想这可能是一个原因。nvm
我在另一个项目 Next.js 14 上工作。所以我使用 nvm 安全地使用了节点 16 -> 18。
# Full Cache Remove
rm -rf node_modules
npm cache clean --force
npm install
watchman watch-del-all
rm -fr $TMPDIR/haste-map-*
rm -rf $TMPDIR/metro-cache
npx expo start --clear
####################
npm install -g --force expo-cli
nvm alias default 16 # 16.20.1
nvm alias default 18 # 18.20.2
npx expo prebuild --clean
# git clone & reinstall
{
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@expo/config-plugins": "~6.0.0",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.14",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-community/datetimepicker": "6.7.3",
"@react-navigation/bottom-tabs": "^6.5.7",
"@react-navigation/core": "^6.4.16",
"@react-navigation/material-bottom-tabs": "^6.2.15",
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"@reduxjs/toolkit": "^1.9.3",
"@tanstack/react-query": "^4.28.0",
"@types/react": "~18.0.27",
"axios": "^1.3.4",
"base-64": "^1.0.0",
"date-fns": "^2.30.0",
"dotenv": "^16.3.1",
"expo": "~48.0.21",
"expo-av": "~13.2.1",
"expo-barcode-scanner": "~12.3.2",
"expo-blur": "~12.2.2",
"expo-dev-client": "~2.2.1",
"expo-device": "~5.2.1",
"expo-image": "~1.0.2",
"expo-linking": "~4.0.1",
"expo-location": "~15.1.1",
"expo-notifications": "~0.18.1",
"expo-secure-store": "~12.1.1",
"expo-splash-screen": "~0.18.2",
"expo-status-bar": "~1.4.4",
"expo-system-ui": "~2.2.1",
"expo-updates": "~0.16.4",
"framer-motion": "^10.9.1",
"js-sha256": "^0.10.1",
"jwt-decode": "^3.1.2",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-devtools": "^4.27.4",
"react-native": "0.71.14",
"react-native-animatable": "^1.3.3",
"react-native-dotenv": "^3.4.9",
"react-native-maps": "1.3.2",
"react-native-paper": "^5.5.1",
"react-native-razorpay": "^2.3.0",
"react-native-recaptcha-that-works": "^1.3.2",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-svg": "13.4.0",
"react-native-vector-icons": "^9.2.0",
"react-native-webview": "11.26.0",
"react-redux": "^8.0.5",
"redux-devtools-extension": "^2.13.9",
"remote-redux-devtools": "^0.5.16",
"tailwindcss": "3.2.7",
"typescript": "^4.9.4"
},
"devDependencies": {
"@babel/core": "^7.20.2"
},
"private": true
}
我认为可能的原因是它以某种方式自动更新到 expo 50(崩溃了)。
经过2天的调试,这是expo问题无法修复,所以我更新到expo 50
更新很容易。确保您的所有库都支持 expo 的更高版本
我遵循了
中提到的更新工作流程https://docs.expo.dev/workflow/upgrading-expo-sdk-walkthrough/