我正在使用Ionic框架和AngularJS構建應用程序。它曾經運行良好,現在它一旦在模擬器和Android設備中啓動就會崩潰。奇怪的是它在Ionic View應用程序中運行良好(http://view.ionic.io/)。 logcat說這個錯誤是一個NullPointerException。Android模擬器和設備上的離子應用程序崩潰
真正令我擔心的是我沒有做任何大的改變,另一個應用程序也開始失敗。 Ionic Cordova如何失敗?
完整的logcat墜機的部分說:
--------- beginning of crash
E/AndroidRuntime(2227): FATAL EXCEPTION: main
E/AndroidRuntime(2227): Process: com.ionicframework.notpush921844, PID: 2227
E/AndroidRuntime(2227): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ionicframework.notpush921844/com.ionicframework.notpush921844.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime(2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
E/AndroidRuntime(2227): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
E/AndroidRuntime(2227): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime(2227): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime(2227): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(2227): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(2227): at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(2227): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(2227): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(2227): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(2227): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
E/AndroidRuntime(2227): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CordovaPlugin.privateInitialize(java.lang.String, org.apache.cordova.CordovaInterface, org.apache.cordova.CordovaWebView, org.apache.cordova.CordovaPreferences)' on a null object reference
E/AndroidRuntime(2227): at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169)
E/AndroidRuntime(2227): at org.apache.cordova.PluginManager.startupPlugins(PluginManager.java:95)
E/AndroidRuntime(2227): at org.apache.cordova.PluginManager.init(PluginManager.java:84)
E/AndroidRuntime(2227): at org.apache.cordova.CordovaWebViewImpl.init(CordovaWebViewImpl.java:116)
E/AndroidRuntime(2227): at org.apache.cordova.CordovaActivity.init(CordovaActivity.java:138)
E/AndroidRuntime(2227): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:209)
E/AndroidRuntime(2227): at com.ionicframework.notpush921844.MainActivity.onCreate(MainActivity.java:32)
E/AndroidRuntime(2227): at android.app.Activity.performCreate(Activity.java:5937)
E/AndroidRuntime(2227): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime(2227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime(2227): ... 10 more
W/ActivityManager(1219): Force finishing activity com.ionicframework.notpush921844/.MainActivity
I/WindowManager(1219): Screenshot max retries 4 of Token{f511ccd ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}} appWin=Window{1adfb8c9 u0 Starting com.ionicframework.notpush921844} drawState=4
E/ActivityManager(1219): Invalid thumbnail dimensions: 576x576
D/OpenGLRenderer(1219): Render dirty regions requested: true
D/Atlas (1219): Validating map...
D/ (1219): HostConnection::get() New Host Connection established 0x9de19530, tid 2264
I/OpenGLRenderer(1219): Initialized EGL, version 1.4
D/OpenGLRenderer(1219): Enabling debug mode 0
W/EGL_emulation(1219): eglSurfaceAttrib not implemented
W/OpenGLRenderer(1219): Failed to set EGL_SWAP_BEHAVIOR on surface 0x9de3eb40, error=EGL_SUCCESS
W/ActivityManager(1219): Activity pause timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
W/EGL_emulation(1475): eglSurfaceAttrib not implemented
W/OpenGLRenderer(1475): Failed to set EGL_SWAP_BEHAVIOR on surface 0xb0a93b40, error=EGL_SUCCESS
W/OpenGLRenderer(1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer(1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
W/OpenGLRenderer(1475): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
I/iu.UploadsManager(1746): End new media; added: 0, uploading: 0, time: 28 ms
V/ConfigFetchTask(1746): ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1ViXdAKZc6rqCAOLFv7YJuwVLSY9_n4gaUyYMJPnZLeFSYFobS5FdRKHo-hnBvGnh1pycqXDTZLbzD-k5JtupkV7UW73Ugga_ju-VhYkvWRtl_Jn90jZhoDq_QYlbboOgPzzxDKH54r4FIa2bH3M1p-U8uzShc-PuRzDfha4UOokdUFujGIG2kLo5vTf6UKiU8mrJ_i-n_s1sm2CNkFb7o3Q7f_N1keqlCKSvXmpOQwTd0C7WGOOCYVnk7105hhiah5iLKl_0ZmwnXt9YnD2hVSUAQyDJPeLsFPksOqBpS6WQgtxBQ
I/GoogleURLConnFactory(1746): Using platform SSLCertificateSocketFactory
W/ActivityThread(1746): ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());
I/ActivityManager(1219): Waited long enough for: ServiceRecord{39917cb u0 com.android.calendar/.alerts.InitAlarmsService}
I/ConfigFetchService(1746): fetch service done; releasing wakelock
I/ConfigFetchService(1746): stopping self
W/ActivityManager(1219): Activity destroy timeout for ActivityRecord{230d3264 u0 com.ionicframework.notpush921844/.MainActivity t61 f}
I/CheckinService(1746): Done disabling old GoogleServicesFramework version
I/ConfigService(1598): onDestroy
D/TaskPersister(1219): removeObsoleteFile: deleting file=61_task.xml
D/InitAlarmsService(2008): Clearing and rescheduling alarms.
I/ActivityManager(1219): Killing 1538:com.android.printspooler/u0a42 (adj 15): empty #17
W/libprocessgroup(1219): failed to open /acct/uid_10042/pid_1538/cgroup.procs: No such file or directory
W/AudioTrack(1219): AUDIO_OUTPUT_FLAG_FAST denied by client
I/Process (2227): Sending signal. PID: 2227 SIG: 9
I/ActivityManager(1219): Process com.ionicframework.notpush921844 (pid 2227) has died
D/OpenGLRenderer(1219): endAllStagingAnimators on 0xa2fe5880 (RippleDrawable) with handle 0x9deaf750
W/InputMethodManagerService(1219): Window already focused, ignoring focus gain of: [email protected] attribute=null, token = [email protected]
真的讓我擔心的是我沒有做任何重大改變?你有沒有把你的項目交給Crossover? (personnaly,crossover崩潰了我所有的項目;))你有沒有添加/刪除cordova插件?我建議你去離子平臺rm android&ionic平臺在重建之前添加android – aorfevre
你是對的,就是這樣。它現在工作正常,謝謝。 –