skip to Main Content

I made a react app and it was working fine using the expo app to test it. I built in for production and on my phone I found it would open once and crash every other time if it would open after building. (I am using android 13) I sent it to a friend using android 11 and it works perfectly. I believe the problem is with one of the packages I am using.

So I have changed and some of the packages and added information in the app.json file as I have seen on other stackoverflow posts but have not had any luck.

app.json

{
  "expo": {
    "name": "Finder",
    "slug": "finder",
    "version": "2.3.1",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "apple.spoonfinder.ml"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.im_the_tea_drinker.spoon_finder"
    },
    "web": {
      "favicon": "./assets/icon.png"
    },
    "extra": {
      "eas": {
        "projectId": "2f14cfae-f990-4aab-9d8e-ca06ea8bec1d"
      }
    }
  }
}

These are the packages that I am using



{
  "name": "finder",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "~47.0.8",
    "expo-cli": "^6.0.8",
    "expo-location": "~15.0.1",
    "expo-permissions": "~14.0.0",
    "expo-sensors": "~12.0.1",
    "expo-status-bar": "~1.4.2",
    "geolib": "^3.3.3",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-native": "0.70.5"
  },
  "devDependencies": {
    "@babel/core": "^7.19.3"
  },
  "private": true
}

Does any one know what could be causing this and how I can fix it?

4

Answers


  1. Chosen as BEST ANSWER

    So the problem was the expo sensor functions were some times returning undefined, to all we had to do is check if it was true. This was the fix.

    DeviceMotion.setUpdateInterval(200);
          DeviceMotion.addListener((motion) => {
            let heading = 0
            //check if heading is available
            if ( motion?.rotation?.alpha ) {
              heading = motion.rotation.alpha;
              heading = heading * (180 / Math.PI);
              heading = heading - angle;
              if (heading < 0) {
                heading = 360 + heading;
              }
              heading -= 90;
    
    
              setAngle(heading);
            }
            
          });
    

  2. this is an issue with your xml file. you have to set exported property to true. this is an example of react-native cli. you have to do it with expo. I don’t know much about expo.

    <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
            android:launchMode="singleTask"
            android:windowSoftInputMode="adjustResize"
            android:exported="true">. <!--  this purports --> 
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
          </activity>
    
    Login or Signup to reply.
  3. Put this in manifest of Android Project.

    <manifest ...> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33" /> </manisfest>

    And Build again.

    Login or Signup to reply.
  4. app/build.gradle

    dependencies {
    implementation 'androidx.work:work-runtime:2.7.1' 
    implementation'androidx.work:work-runtime-ktx:2.7.1'}
    

    And Build again

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search