“不幸的是,在Android上恢复我的Phonegap应用程序时,<myapp>已停止”</myapp>

时间:2013-06-05 02:21:36

标签: android cordova restore

当我启动我的应用程序时,让它继续运行并稍后再回到它并点击我经常得到的应用程序图标,“不幸的是,已停止”。然后我再次运行它很好。起初我认为这是因为任务杀手,但我从杀戮名单中删除它,我仍然得到它。调试转储如下:

06-04 15:06:35.700: E/Trace(22780): error opening trace file: No such file or directory (2)
06-04 15:06:35.700: D/ActivityThread(22780): setTargetHeapUtilization:0.25
06-04 15:06:35.700: D/ActivityThread(22780): setTargetHeapIdealFree:8388608
06-04 15:06:35.700: D/ActivityThread(22780): setTargetHeapConcurrentStart:2097152
06-04 15:06:35.800: D/webcoreglue(22780): netstack: Memory Cache feature is ON
06-04 15:06:35.820: I/CordovaLog(22780): Changing log level to DEBUG(3)
06-04 15:06:35.820: I/CordovaLog(22780): Found preference for useBrowserHistory=false
06-04 15:06:35.820: D/CordovaLog(22780): Found preference for useBrowserHistory=false
06-04 15:06:35.820: I/CordovaLog(22780): Found preference for exit-on-suspend=false
06-04 15:06:35.820: D/CordovaLog(22780): Found preference for exit-on-suspend=false
06-04 15:06:35.820: W/CordovaWebView(22780): useBrowserHistory=false is deprecated as of Cordova 2.2.0 and will be removed six months after the 2.2.0 release.  Please use the browser history and use history.back().
06-04 15:06:35.830: D/JsMessageQueue(22780): Set native->JS mode to 2
06-04 15:06:35.830: D/DroidGap(22780): DroidGap.init()
06-04 15:06:35.840: D/LMLC(22780): After Restoring the state
06-04 15:06:35.840: D/LMLC(22780): In onRestoreInstanceState
06-04 15:06:35.840: D/LMLC(22780): After onRestoreInstanceState
06-04 15:06:35.840: D/LMLC(22780): After restoreState
06-04 15:06:35.840: D/DroidGap(22780): Resuming the App
06-04 15:06:35.860: D/SoftKeyboardDetect(22780): Ignore this event
06-04 15:06:35.880: D/libEGL(22780): loaded /system/lib/egl/libEGL_adreno200.so
06-04 15:06:35.900: D/libEGL(22780): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
06-04 15:06:35.900: D/libEGL(22780): loaded /system/lib/egl/libGLESv2_adreno200.so
06-04 15:06:35.950: V/chromium(22780): external/chromium/net/host_resolver_helper/host_resolver_helper.cc:66: [0604/150635:INFO:host_resolver_helper.cc(66)] DNSPreResolver::Init got hostprovider:0x4d125010
06-04 15:06:35.950: V/chromium(22780): external/chromium/net/base/host_resolver_impl.cc:1510: [0604/150635:INFO:host_resolver_impl.cc(1510)] HostResolverImpl::SetPreresolver preresolver:0x4be93670
06-04 15:06:35.950: D/HostStatisticManager(22780): netstack: DNS Host Prioritization is: ON, Version: 5.0.1
06-04 15:06:35.970: D/(22780): dl error message Cannot load library: load_library[1093]: Library 'libtcpfinaggr.so' not found
06-04 15:06:35.970: D/Socket_Pool(22780): Failed to create TCP Fin Aggregation interface.
06-04 15:06:35.970: D/Socket_Pool(22780): netstack: CloseUnusedSockets is ON
06-04 15:06:35.970: D/Socket_Pool(22780): netstack: system net.statistics value: 0
06-04 15:06:35.970: D/Socket_Pool(22780): Failed to create TCP Fin Aggregation interface.
06-04 15:06:35.970: D/Socket_Pool(22780): netstack: CloseUnusedSockets is ON
06-04 15:06:35.970: D/Socket_Pool(22780): netstack: system net.statistics value: 0
06-04 15:06:35.970: D/(22780): external/chromium/net/http/http_getzip_factory.cc: Failed to construct GETzip manager, didn't find the library!
06-04 15:06:35.980: I/Adreno200-EGLSUB(22780): <ConfigWindowMatch:2087>: Format RGBA_8888.
06-04 15:06:36.081: E/(22780): <s3dReadConfigFile:75>: Can't open file for reading
06-04 15:06:36.081: E/(22780): <s3dReadConfigFile:75>: Can't open file for reading
06-04 15:06:36.081: D/OpenGLRenderer(22780): Enabling debug mode 0
06-04 15:06:36.171: D/DroidGap(22780): onMessage(onPageStarted,file:///android_asset/www/index.html)
06-04 15:06:36.181: D/SoftKeyboardDetect(22780): Ignore this event
06-04 15:06:36.321: D/netstack(22780): netstack: Request Priority is ON
06-04 15:06:36.641: D/chromium(22780): Unknown chromium error: -6
06-04 15:06:36.941: D/Cordova(22780): onPageFinished(file:///android_asset/www/index.html)
06-04 15:06:36.941: D/AndroidRuntime(22780): Shutting down VM
06-04 15:06:36.941: W/dalvikvm(22780): threadid=1: thread exiting with uncaught exception (group=0x40d01438)
06-04 15:06:36.951: E/AndroidRuntime(22780): FATAL EXCEPTION: main
06-04 15:06:36.951: E/AndroidRuntime(22780): java.lang.NullPointerException
06-04 15:06:36.951: E/AndroidRuntime(22780):    at java.lang.String.indexOf(String.java:994)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at org.apache.cordova.CordovaWebView.loadUrlNow(CordovaWebView.java:517)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at org.apache.cordova.CordovaWebView.loadUrl(CordovaWebView.java:402)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at org.apache.cordova.CordovaWebViewClient.onPageFinished(CordovaWebViewClient.java:298)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:327)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at android.os.Looper.loop(Looper.java:137)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at android.app.ActivityThread.main(ActivityThread.java:5021)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at java.lang.reflect.Method.invokeNative(Native Method)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at java.lang.reflect.Method.invoke(Method.java:511)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-04 15:06:36.951: E/AndroidRuntime(22780):    at dalvik.system.NativeStart.main(Native Method)
06-04 15:06:38.603: V/chromium(22780): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:52: [0604/150638:INFO:hostres_plugin_bridge.cc(52)] StatHubCreateHostResPlugin initializing...
06-04 15:06:38.603: V/chromium(22780): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:57: [0604/150638:INFO:hostres_plugin_bridge.cc(57)] StatHubCreateHostResPlugin lib loaded
06-04 15:06:38.603: V/chromium(22780): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:63: [0604/150638:INFO:hostres_plugin_bridge.cc(63)] StatHubCreateHostResPlugin plugin connected
06-04 15:06:38.603: V/chromium(22780): external/chromium/net/http/http_cache.cc:1168: [0604/150638:INFO:http_cache.cc(1168)] HttpCache::OnBackendCreated HostStat created
06-04 15:06:38.603: E/chromium(22780): external/chromium/net/disk_cache/stat_hub.cc:216: [0604/150638:ERROR:stat_hub.cc(216)] StatHub::Init - App com.lmlc.lawnpro isn't supported.
06-04 15:06:38.633: V/chromium(22780): external/chromium/net/disk_cache/hostres_plugin_bridge.cc:73: [0604/150638:INFO:hostres_plugin_bridge.cc(73)] netstack: Failed to find symbols in plugin: libdnshostprio.so
06-04 15:06:38.633: E/chromium(22780): external/chromium/net/disk_cache/stat_hub.cc:216: [0604/150638:ERROR:stat_hub.cc(216)] StatHub::Init - App com.lmlc.lawnpro isn't supported.
06-04 15:06:38.633: D/(22780): netstack: Early Connections is: ON, Version: 5.0.1, Param: 3

Java代码

  package com.lmlc.lawnpro;

  import org.apache.cordova.DroidGap;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.webkit.WebView;

  public class MainActivity extends DroidGap {

      private JavascriptInterface jSInterface;
      protected WebView webView;

     @Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
        jSInterface = new JavascriptInterface(this, appView);
        appView.addJavascriptInterface(jSInterface, "JICls");

         //setContentView(R.layout.activity_main);

          if(savedInstanceState == null || savedInstanceState.isEmpty())
        {
           super.loadUrl("file:///android_asset/www/index.html");
           Log.d("LMLCPro", "super.loadUrl");
        }
          else
          {
           this.appView.restoreState(savedInstanceState);
           Log.d("LMLC", "After Restoring the state");
        }

        //setContentView(R.layout.activity_main);
         //super.loadUrl("file:///android_asset/www/index.html");
     }

     @Override
     protected void onSaveInstanceState(Bundle outState)
     {
         Log.d("LMLC", "In onSaveInstanceState");
        super.onSaveInstanceState(outState);
         Log.d("LMLC", "After onSaveInstanceState");
         this.appView.saveState(outState);
         Log.d("LMLC", "After saveState");
  //          outState.putBoolean("MyBoolean", true);
  //          outState.putDouble("myDouble", 1.9);
  //          outState.putInt("MyInt", 1);
  //          outState.putString("MyString", "Welcome back to Android");


     }

     @Override
     protected void onRestoreInstanceState(Bundle savedInstanceState)
     {
         Log.d("LMLC", "In onRestoreInstanceState");
         super.onRestoreInstanceState(savedInstanceState);
         Log.d("LMLC", "After onRestoreInstanceState");
        // Restore the state of the WebView
         this.appView.restoreState(savedInstanceState);
         Log.d("LMLC", "After restoreState");
     }
  /*
      @Override
      public void onResume() {
          super.onResume();
          this.appView.handleResume(true, false);
      }
  */
      @Override
      public void onPause() {
          super.onPause();
          String url = this.appView.peekAtUrlStack();
          this.appView.handlePause(true);

          Bundle out = new Bundle();
          this.appView.saveState(out);
          out.putString("url", url);

          //saveToPreferences(out);

      }

      @Override
      public void onStop() {
          super.onStop();
      }

     @Override
      public void onDestroy() {
          super.onDestroy();

      }

     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
     }


     public class JavascriptInterface {

          //private WebView mAppView;
          private MainActivity mGap;

          public JavascriptInterface(MainActivity gap, WebView view)
          {
  //            mAppView = view;
            mGap = gap;
          }

        }


  }

1 个答案:

答案 0 :(得分:0)

我将.jar文件和cordova javascript文件升级到2.7。我还删除了2行代码:

String url = this.appView.peekAtUrlStack();
out.putString("url", url);

这似乎解决了它。