安卓错误:MainActivity上需要类、接口或枚举。JAVA
我正在尝试编译一个利用Android Studio上的Expo的应用程序,但是,每次尝试时,我都会收到以下错误消息:
\安卓\app\src\main\java\com\profileid\MainActivity.java:2: error: class, interface, or enum expected
package com.projectname;
我刚刚升级到Expo SDK 43,并从^{
我的主要活动。java看起来像这样:
import expo.modules.ReactActivityDelegateWrapper;
package com.projectname;
import 安卓.os.Bundle;
import com.facebook.react.ReactActivity;
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 ReactActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 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);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "main";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegateWrapper(this, new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
});
}
}
# 1 楼答案
您的第一个
import
语句和package
语句出现故障。package
语句必须是文件的第一行: