簡體   English   中英

發布到 Testflight 時 React Native Expo 應用程序崩潰

[英]React Native Expo app crashing when published to Testflight

我有一個使用位置權限的 React Native Expo 應用程序。 它在我的設備和模擬器上運行良好,因此進入分發的下一步 - TestFlight。 當我將 ipa 加載到 Testflight 然后嘗試運行該應用程序時,該應用程序可以運行到我向用戶請求權限的程度。 (因此應用程序加載,身份驗證有效,到我的服務器和數據庫的鏈接都有效等)。

在代碼請求用戶位置權限時,通常的警報“使用應用程序時允許,始終允許,不允許”在屏幕上閃爍幾毫秒,然后應用程序崩潰,我可以選擇將評論分享給試飛。

請求許可的代碼在這里:

import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
import createDataContext from '../../Context/createDataContext';

const deviceLocationReducer = (state, action) => {
  switch (action.type) {
    case 'get_device_location':
      return action.payload;
    default:
      return state;
  }
};

const getDeviceLocation = dispatch => async () => {
  let deviceLocation = null;
  try {
    // Ask User permission for location
    const { status } = await Permissions.askAsync(Permissions.LOCATION);
    console.log('\n***\nDeviceLocationContext.js: Permission status', status);
    if (status === 'granted') {
      // Permission granted, get user location
      deviceLocation = await Location.getCurrentPositionAsync({});
      console.log('DeviceLocationContext.js: Setting Context', deviceLocation);
    } else {
      console.log(
        'DeviceLocationContext.js: Permission to access location denied'
      );
    }

    dispatch({
      type: 'get_device_location',
      payload: deviceLocation,
    });
  } catch ({ message }) {
    console.log(
      `DeviceLocationContext.js: Get Device Location Error: ${message}`
    );
  }
};

export const { Context, Provider } = createDataContext(
  deviceLocationReducer,
  { getDeviceLocation },
  null
);

app.json 在這里

{
  "expo": {
    "name": "MyApp",
    "description": "MyApp Description",
    "slug": "client",
    "privacy": "public",
    "sdkVersion": "35.0.0",
    "platforms": ["ios", "android"],
    "version": "0.0.7",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "splash": {
      "image": "./assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.reachout.myapp",
      "icon": "./assets/images/icon.png",
      "infoPlist": {
        "NSCameraUsageDescription": "Please allow access to add your photo.",
        "NSPhotoLibraryUsageDescription": "Please allow access to select an image from your photo library.",
        "NSLocationWhenInUseUsageDescription": "Please allow access to show venues near you"
      },
      "buildNumber": "0.0.7"
    },
    "android": {
      "permissions": [
        "CAMERA",
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION"
      ],
      "versionCode": 7,
      "icon": "./assets/images/icon.png"
    }
  }
}

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"
  },
  "dependencies": {
    "@expo/vector-icons": "^10.0.6",
    "axios": "^0.19.0",
    "expo": "^35.0.0",
    "expo-camera": "^7.0.0",
    "expo-constants": "~7.0.0",
    "expo-font": "^7.0.0",
    "expo-image-picker": "~7.0.0",
    "expo-location": "~7.0.0",
    "expo-permissions": "^7.0.0",
    "lodash": "^4.17.15",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
    "react-native-elements": "^1.2.7",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-image-picker": "^1.1.0",
    "react-native-map-clustering": "^3.0.6",
    "react-native-maps": "^0.26.1",
    "react-native-paper": "^3.1.1",
    "react-native-ratings": "^6.5.0",
    "react-native-reanimated": "^1.2.0",
    "react-native-web": "^0.11.7",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.9.4",
    "react-navigation-tabs": "^2.5.6"
  },
  "devDependencies": {
    "babel-eslint": "^9.0.0",
    "babel-preset-expo": "^7.0.0",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^17.1.1",
    "eslint-config-prettier": "^4.3.0",
    "eslint-config-wesbos": "0.0.19",
    "eslint-plugin-html": "^5.0.5",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-prettier": "^3.1.1",
    "eslint-plugin-react": "^7.16.0",
    "eslint-plugin-react-hooks": "^1.7.0",
    "prettier": "^1.19.1"
  },
  "private": true
}

有沒有人有任何想法? 我完全空白 - 我已經在生產和開發中運行了世博會的構建,我已經清除了世博會緩存,我已經從我的設備中刪除了應用程序並再次加載 - 一切都無濟於事。

所以我有一個“工作”應用程序,我無法分發它進行測試。 幫助!!

另外 - 我不知道如何在 Testflight 上為世博會構建的應用程序調試或訪問崩潰數據 - 再次 - 非常感謝任何幫助。 謝謝。

已解決 :) - 會離開這里以防萬一其他人遇到這種問題,因為這個問題讓我卡住了幾天並進行了構建。

我的問題是我從一個也安裝了 Mapview 的組件中要求用戶在 useEffect 鈎子中的位置。 在 Mapview 中,我將provider prop 設置為google

如果你這樣做,那么你必須在你的信息 plist 中添加一個 gogleMapApi 鍵。 公平地說,Expo 確實在 MapView 文檔中說明了這一點,但它在 Android 文檔之后作為旁白放在底部。 在瀏覽我的日志幾個小時后,我意識到我的問題和這個線程的解決方案,發現問題是谷歌 api 錯誤,而不是權限位置錯誤。

[ https://forums.expo.io/t/how-to-set-googlemaps-with-gmsservices-provideapikey/17770][1]

希望這可以幫助某人!

我還面臨無法識別 JS 錯誤的問題,我想分享如何調試它。

對於 iOS,您可以使用模擬器選項構建獨立應用程序,崩潰日志存儲在此處:

~/Library/Logs/DiagnosticReports/

我在這里寫了更多細節。

https://medium.com/@tak215/expo-rash-on-standalone-app-only-how-to-debug-29c88c69c821?sk=babf382671e1c8c5bf97a74773d4f4f5

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM