Expo SDK 50 WebView下载异常:Expo Go正常,Android APK打包后失败
Expo SDK 50升级后Android打包APK中WebView文档下载失败,但Expo Go正常
近期将Expo项目从SDK 48升级至SDK 50后,原通过WebView实现的文档下载功能出现异常:
- Expo Go中测试时文档下载可正常完成
- 打包为Android APK后,API通信正常,但文档下载失败并提示错误信息
使用expo-web-browser模块实现的文档下载在Expo Go和打包后的应用中均可正常运行:
import * as WebBrowser from 'expo-web-browser'; WebBrowser.openBrowserAsync(webViewSource);
但原WebView方案在打包APK后仍无法正常下载,该问题仅出现在Android平台,无法定位根因,寻求解决。
已尝试的方案
- 替换为
expo-web-browser模块实现下载,此方案可正常工作,但希望保留原WebView方案
app.json
{ "expo": { "name": "tablet", "slug": "tablet-web", "version": "1.3.3", "orientation": "landscape", "icon": "./assets/icon/appstore.png", "scheme": "tabletwebdev", "splash": { "image": "./assets/images/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "updates": { "fallbackToCacheTimeout": 0, "url": "https://u.expo.dev/bfd33934-43f2-4d71-bfe4-d89f01a8c0f9" }, "assetBundlePatterns": [ "**/*" ], "ios": { "supportsTablet": true }, "android": { "package": "com.tablet.tabletweb", "config": { "googleMaps": { "apiKey": "AIzaSyBNWwM2b8bnh5mXJFk7_DhDb87yhqOnuZM" } }, "adaptiveIcon": { "foregroundImage": "./assets/icon/appstore.png", "backgroundColor": "#ffffff" } }, "web": { "favicon": "./assets/images/favicon.png" }, "androidStatusBar": { "hidden": true }, "extra": { "eas": { "projectId": "bfd33934-43f2-4d71-bfe4-d89f01a8c0f9" } }, "runtimeVersion": { "policy": "nativeVersion" }, "plugins": [ [ "expo-build-properties", { "android": { "ProguardInReleaseBuilds": true } } ] ] }, "plugins": [ [ "expo-media-library", { "photosPermission": "Allow $(PRODUCT_NAME) to access your photos.", "savePhotosPermission": "Allow $(PRODUCT_NAME) to save photos.", "isAccessMediaLocationEnabled": true } ] ] }
package.json
{ "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject", "test": "jest --watchAll", "devtools": "react-devtools", "postinstall": "patch-package" }, "jest": { "preset": "jest-expo" }, "dependencies": { "@actbase/react-daum-postcode": "^1.0.4", "@expo/config-plugins": "~6.0.0", "@expo/vector-icons": "^13.0.0", "@expo/webpack-config": "^18.0.1", "@hauvo/react-native-360-image-viewer": "^1.0.0", "@react-native-async-storage/async-storage": "1.17.11", "@react-native-community/datetimepicker": "6.7.3", "@react-native-community/slider": "^4.4.2", "@react-native-picker/picker": "2.4.8", "@react-navigation/bottom-tabs": "^6.5.8", "@react-navigation/elements": "^1.3.18", "@react-navigation/native": "^6.1.7", "@react-navigation/native-stack": "^6.9.13", "@react-navigation/stack": "^6.3.17", "@types/react-native-snap-carousel": "^3.8.5", "@types/react-redux": "^7.1.25", "axios": "^0.27.2", "crypto-js": "^4.2.0", "deprecated-react-native-prop-types": "^4.2.0", "expo": "~48.0.18", "expo-asset": "~8.9.1", "expo-av": "~13.2.1", "expo-build-properties": "~0.6.0", "expo-camera": "~13.2.1", "expo-checkbox": "~2.3.1", "expo-constants": "~14.2.1", "expo-dev-client": "~2.2.1", "expo-device": "~5.2.1", "expo-font": "~11.1.1", "expo-intent-launcher": "~10.5.2", "expo-linear-gradient": "~12.1.2", "expo-linking": "~4.0.1", "expo-location": "~15.1.1", "expo-media-library": "~15.2.3", "expo-navigation-bar": "~2.1.1", "expo-screen-orientation": "~5.1.1", "expo-secure-store": "~12.1.1", "expo-splash-screen": "~0.18.2", "expo-status-bar": "~1.4.4", "expo-updates": "~0.16.4", "expo-web-browser": "~12.1.1", "jsencrypt": "^3.3.2", "lodash": "^4.17.21", "nanoid": "^4.0.2", "patch-package": "^7.0.2", "postinstall-postinstall": "^2.1.0", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.71.8", "react-native-bouncy-checkbox": "^3.0.7", "react-native-easy-grid": "^0.2.2", "react-native-elements": "^3.4.3", "react-native-error-boundary": "^1.2.3", "react-native-gesture-handler": "~2.9.0", "react-native-loading-spinner-overlay": "^3.0.1", "react-native-maps": "1.3.2", "react-native-modal": "^13.0.1", "react-native-pager-view": "6.1.2", "react-native-reanimated": "~2.14.4", "react-native-redash": "^18.1.0", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", "react-native-signature-canvas": "^4.5.1", "react-native-snap-carousel": "^3.9.1", "react-native-view-shot": "3.5.0", "react-native-web": "~0.18.10", "react-native-webview": "11.26.0", "react-redux": "^8.0.1", "redux": "^4.2.0", "redux-observable": "^2.0.0", "rxjs": "^7.5.5", "typesafe-actions": "^5.1.0" }, "devDependencies": { "@babel/core": "^7.22.9", "@types/crypto-js": "^4.2.1", "@types/lodash": "^4.14.195", "@types/mime": "^3.0.1", "@types/react": "~18.0.27", "babel-plugin-module-resolver": "^5.0.0", "jest": "^29.6.1", "jest-expo": "^48.0.1", "react-native-svg-transformer": "^1.1.0", "react-test-renderer": "^18.2.0", "typescript": "^4.9.4" }, "private": true }
内容的提问来源于stack exchange,提问作者최서환
相关产品推荐
相关产品推荐

