2017-08-11 74 views
0

react-native-smart-splash-screen/android/src/main/java/com/reactnativecomponent/splashscreen/RCTSplashScreenPackage.java:23:error:方法未覆盖或实现从超类型 @Override ^ 1错误 的方法:反应天然-智能溅射屏幕:compileReleaseJavaWithJavac FAILED错误:react-native-smart-splashscreen

FAILURE:建立失败,异常。

  • 出了什么问题: 执行失败的任务“:反应母语 - 智能启动画面:compileReleaseJavaWithJavac”。

    Compilation failed; see the compiler error output for details.

  • 尝试: 与--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

请澄清你的问题是什么,以及你已经做了什么来尝试修复它。 https://stackoverflow.com/help/how-to-ask – Kai

回答

1

是的,这是RN 0.47.1更新后最常见的错误。 您可以查看最新版本here

在发布中声明删除未使用的createJSModules调用。 因此,在您的RCTSplashScreenPackage删除或注释这些行:

@Override 
public List<Class<? extends JavaScriptModule>> createJSModules() { 
    return Collections.emptyList(); 
} 

我希望这有助于大家。

+0

为我工作......谢谢! –