f111fei / react-native-unity-view

Show an unity view in react native
MIT License
402 stars 102 forks source link

Android app crashes on startup. #120

Closed Apetrou closed 5 years ago

Apetrou commented 5 years ago

Hi, I'm having issues with my app crashing as soon as it starts up. I get the following error trace on logcat:

06-24 21:46:15.111 6650 6650 E AndroidRuntime: FATAL EXCEPTION: main 06-24 21:46:15.111 6650 6650 E AndroidRuntime: Process: com.xxxx, PID: 6650 06-24 21:46:15.111 6650 6650 E AndroidRuntime: java.lang.Error: Unresolved compilation problems: 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import android.app cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.facebook.react.ReactApplication cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.swmansion.gesturehandler.react.RNGestureHandlerPackage cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.facebook.react.ReactNativeHost cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.facebook.react.ReactPackage cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.facebook.react.shell cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The import com.facebook.soloader.SoLoader cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: Application cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactApplication cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactNativeHost cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactNativeHost cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The method getUseDeveloperSupport() of type new ReactNativeHost(){} must override or implement a supertype method 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactPackage cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The method getPackages() of type new ReactNativeHost(){} must override or implement a supertype method 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactPackage cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: MainReactPackage cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: RNGestureHandlerPackage cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The method getJSMainModuleName() of type new ReactNativeHost(){} must override or implement a supertype method 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactNativeHost cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The method getReactNativeHost() of type MainApplication must override or implement a supertype method 06-24 21:46:15.111 6650 6650 E AndroidRuntime: ReactNativeHost cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: The method onCreate() of type MainApplication must override or implement a supertype method 06-24 21:46:15.111 6650 6650 E AndroidRuntime: Application cannot be resolved to a type 06-24 21:46:15.111 6650 6650 E AndroidRuntime: SoLoader cannot be resolved 06-24 21:46:15.111 6650 6650 E AndroidRuntime: 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at com.xxxx.MainApplication.(MainApplication.java:3) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at java.lang.Class.newInstance(Native Method) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.Instrumentation.newApplication(Instrumentation.java:1120) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.LoadedApk.makeApplication(LoadedApk.java:1061) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5842) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.ActivityThread.access$1100(ActivityThread.java:199) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6669) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 06-24 21:46:15.111 6650 6650 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

I know its this package causing it as when I comment out its references the error stops. I assume what is happening is that the unity view is crashing for some reason and because the unity activity runs in parallel with the main activity it also causes that to crash producing the error of modules not being resolved. Is anyone else having or has had a similar issue and if so how did you deal with it?

Many thanks, Alkis.

itinance commented 4 years ago

@apetrou What was your solution?

Apetrou commented 4 years ago

It was due to an issue with my unity file. When I fixed the issues in the unity file and re exported it worked fine!

itinance commented 4 years ago

It was due to an issue with my unity file. When I fixed the issues in the unity file and re exported it worked fine!

Hey @Apetrou , thanks for reaching out! Can you please describe a bit more in detail what the issue exactly was? Code side? Plugin side? Or something different?

itinance commented 4 years ago

The solution for our issue is this: https://github.com/f111fei/react-native-unity-view/issues/142#issuecomment-557162700