react-native-smart-splash-screen / android / src / main / java / com / reactnativecomponent / splashscreen / RCTSplashScreenPackage.java:23:error:方法不会覆盖或实现超类型的方法 @覆盖 ^ 1错误 :react-native-smart-splashscreen:compileReleaseJavaWithJavac FAILED
失败:构建因异常而失败。
出了什么问题: 任务执行失败':react-native-smart-splashscreen:compileReleaseJavaWithJavac'。
编译失败;有关详细信息,请参阅编译器错误输出。
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。
建立失败
总时间:9.971秒 无法在设备上安装应用程序,请阅读上面的错误以获取详细信息。 确保您正在运行Android模拟器或已连接设备 设置Android开发环境: https://facebook.github.io/react-native/docs/android-setup.html
MainApplication.java
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.github.yamill.orientation.OrientationPackage;
import com.reactnativecomponent.splashscreen.RCTSplashScreenPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new OrientationPackage()
);
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTSplashScreenPackage() //register Module
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
MainActivity.java
import com.facebook.react.ReactActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import com.reactnativecomponent.splashscreen.RCTSplashScreen;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "HeadThink";
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Intent intent = new Intent("onConfigurationChanged");
intent.putExtra("newConfig", newConfig);
this.sendBroadcast(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
RCTSplashScreen.openSplashScreen(this); //open splashscreen
//RCTSplashScreen.openSplashScreen(this, true, ImageView.ScaleType.FIT_XY); //open splashscreen fullscreen
super.onCreate(savedInstanceState);
}
}
RCTSplashScreenPackage
package com.reactnativecomponent.splashscreen;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class RCTSplashScreenPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(
new RCTSplashScreenModule(reactContext)
);
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Arrays.<ViewManager>asList();
}
}
答案 0 :(得分:1)
是的,这是RN 0.47.1更新后出现的最常见错误。 您可以查看最新版本here。
在发布中声明删除未使用的createJSModules调用。 因此,在RCTSplashScreenPackage中删除或注释这些行:
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
我希望这对每个人都有帮助。