2017-08-11 73 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

爲我工作......謝謝! –