【问题标题】:ReactNative ExpoSDK41 Bare wf (Ejected) : Build errors in MainActivity.java - Android buildReact Native Expo SDK 41 Bare wf (Eje​​cted):在 MainActivity.java 中构建错误 - Android 构建
【发布时间】:2021-05-27 05:46:11
【问题描述】:

上下文: 反应原生 世博会 SDK41 裸工作流(已弹出) 安卓构建

在弹出并开始构建时间(EAS Build)之后,我得到了剩下的两个错误: 那些是阻塞的,非常烦人。 我试过了 : - 定义函数 getMainComponentName 以返回我的主要组件名称字符串 -删除一个和两个覆盖 - 删除 getMainComponentName 并放置我的主要组件名称字符串

我卡住了

/build/workingdir/build/android/app/src/main/java/com/satyamdorville/discover/MainActivity.java:34: error: method does not override or implement a method from a supertype

还有:

/build/workingdir/build/android/app/src/main/java/com/satyamdorville/discover/MainActivity.java:36: error: cannot find symbol   
...
  symbol:   method getMainComponentName())

这是我的 mainActivity.java :

package com.satyamdorville.discover;
import android.content.res.Configuration;
import android.content.Intent;
import android.os.Bundle;
import com.reactnativenavigation.NavigationActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import expo.modules.splashscreen.singletons.SplashScreen;
import expo.modules.splashscreen.SplashScreenImageResizeMode;


public class MainActivity extends NavigationActivity {

    // Added automatically by Expo Config
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        Intent intent = new Intent("onConfigurationChanged");
        intent.putExtra("newConfig", newConfig);
        sendBroadcast(intent);
    }



  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(null);
    // SplashScreen.show(...) has to be called after super.onCreate(...)
    // Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
    SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
  }

     @Override
     protected ReactActivityDelegate createReactActivityDelegate() {
         return new ReactActivityDelegate(this, getMainComponentName()) {
             @Override
             protected ReactRootView createRootView() {
                 return new RNGestureHandlerEnabledRootView(MainActivity.this);
             }
         };
     }
}
And package.json :

{
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-async-storage/async-storage": "^1.13.0",
    "@react-native-community/cli-platform-ios": "^5.0.1-alpha.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/bottom-tabs": "5.11.2",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "~5.12.8",
    "@reduxjs/toolkit": "^1.5.1",
    "@sentry/react-native": "^2.4.3",
    "@stripe/stripe-react-native": "^0.1.2",
    "@types/react-native-snap-carousel": "^3.8.3",
    "email-validator": "^2.0.4",
    "expo": "^41.0.0",
    "expo-asset": "~8.3.1",
    "expo-constants": "~10.1.3",
    "expo-font": "^9.1.0",
    "expo-linking": "^2.2.3",
    "expo-location": "^12.0.4",
    "expo-permissions": "^12.0.1",
    "expo-splash-screen": "~0.10.2",
    "expo-status-bar": "^1.0.4",
    "expo-updates": "~0.5.4",
    "expo-web-browser": "~9.1.0",
    "moment-timezone": "^0.5.33",
    "parse": "^3.1.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "~0.63.4",
    "react-native-animatable": "^1.3.3",
    "react-native-appearance": "~0.3.3",
    "react-native-dropdown-picker": "^5.1.15",
    "react-native-elements": "^3.3.2",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-modal": "^11.10.0",
    "react-native-navigation": "^7.12.0",
    "react-native-numeric-input": "^1.9.0",
    "react-native-paper": "^4.8.1",
    "react-native-reanimated": "^2.1.0",
    "react-native-render-html": "^5.1.0",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^3.3.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-stripe-checkout-webview": "0.0.13",
    "react-native-ui-lib": "^5.22.0",
    "react-native-unimodules": "~0.13.3",
    "react-native-vector-icons": "^8.1.0",
    "react-native-web": "~0.13.12",
    "react-native-webview": "^11.2.3",
    "react-navigation": "^4.4.4",
    "react-redux": "^7.2.3",
    "react-ridge-state": "^4.2.1",
    "redux": "^4.0.5",
    "sentry-expo": "^3.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.9.6",
    "@types/lodash": "^4.14.168",
    "@types/react": "~16.9.35",
    "@types/react-native": "~0.63.2",
    "@types/react-redux": "^7.1.16",
    "jest-expo": "^41.0.0",
    "redux-tools": "^3.2.0",
    "typescript": "~4.0.0"
  },
  "private": true,
  "name": "discover",
  "version": "1.0.0"
}

如果您有任何提示可以摆脱此错误。非常感谢 !任何帮助将不胜感激!

【问题讨论】:

    标签: android reactjs react-native expo


    【解决方案1】:

    解决方案就是按照错误所说的去做:

    删除覆盖标签 && 添加:

     protected String getMainComponentName() {
            return "App"; // here
        } 
    

    【讨论】:

      猜你喜欢
      • 2023-02-25
      • 2017-06-26
      • 1970-01-01
      • 2021-07-30
      • 1970-01-01
      • 2019-09-10
      • 2017-11-19
      • 2017-12-26
      • 1970-01-01
      相关资源
      最近更新 更多