2012-12-11 103 views
0

我正在關注教程hereAndroid OCR強制關閉

我已經完成了所有的步驟,當我點擊eclipse中的run時,它似乎在應用程序進入我的手機時工作。

但是,當我點擊它時,我得到一個「強制關閉錯誤」。

當我從我的電腦上拔下手機時,我得到了儘可能多的照片,但是當我去做ocr時,我得到了強制關閉錯誤。

我與Windows 7的工作,閱讀網頁上的評論它應該工作

下面是一些我收到的logcat錯誤的打印 -

@Override 
public void onCreate(Bundle savedInstanceState) { 

    String[] paths = new String[] { DATA_PATH, DATA_PATH + "tessdata/" }; 

    for (String path : paths) { 
     File dir = new File(path); 
     if (!dir.exists()) { 
      if (!dir.mkdirs()) { 
       Log.v(TAG, "ERROR: Creation of directory " + path + " on sdcard failed"); 
       return; 
      } else { 
       Log.v(TAG, "Created directory " + path + " on sdcard"); 
      } 
     } 

    } 

    // lang.traineddata file with the app (in assets folder) 
    // You can get them at: 
    // http://code.google.com/p/tesseract-ocr/downloads/list 
    // This area needs work and optimization 
    if (!(new File(DATA_PATH + "tessdata/" + lang + ".traineddata")).exists()) { 
     try { 

      AssetManager assetManager = getAssets(); 
      InputStream in = assetManager.open("tessdata/eng.traineddata"); 
      //GZIPInputStream gin = new GZIPInputStream(in); 
      OutputStream out = new FileOutputStream(DATA_PATH 
        + "tessdata/eng.traineddata"); 

      // Transfer bytes from in to out 
      byte[] buf = new byte[1024]; 
      int len; 
      //while ((lenf = gin.read(buff)) > 0) { 
      while ((len = in.read(buf)) > 0) { 
       out.write(buf, 0, len); 
      } 
      in.close(); 
      //gin.close(); 
      out.close(); 

      Log.v(TAG, "Copied " + lang + " traineddata"); 
     } catch (IOException e) { 
      Log.e(TAG, "Was unable to copy " + lang + " traineddata " + e.toString()); 
     } 
    } 

    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main); 

    // _image = (ImageView) findViewById(R.id.image); 
    _field = (EditText) findViewById(R.id.field); 
    _button = (Button) findViewById(R.id.button); 
    _button.setOnClickListener(new ButtonClickHandler()); 

    _path = DATA_PATH + "/ocr.jpg"; 
    //_path = DATA_PATH + "/shuffledDigits.jpg"; 

} 

錯誤日誌

12-11 18:09:14.097: E/jdwp(926): Failed sending req to debugger: Broken pipe (-1 of 27) 
    12-11 18:09:14.097: E/jdwp(926): Failed sending req to debugger: Broken pipe (-1 of 27) 
    12-11 18:09:14.097: E/jdwp(926): Failed sending reply to debugger: Broken pipe 
    12-11 18:09:14.287: V/SimpleAndroidOCR.java(926): ERROR: Creation of directory /sdcard/SimpleAndroidOCR/ on sdcard failed 
    12-11 18:09:14.287: D/AndroidRuntime(926): Shutting down VM 
    12-11 18:09:14.287: W/dalvikvm(926): threadid=3: thread exiting with uncaught exception (group=0x40026160) 
    12-11 18:09:14.287: E/AndroidRuntime(926): Uncaught handler: thread main exiting due to uncaught exception 
    12-11 18:09:14.306: E/AndroidRuntime(926): android.app.SuperNotCalledException: Activity {com.datumdroid.android.ocr.simple/com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity} did not call through to super.onCreate() 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2468) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.os.Handler.dispatchMessage(Handler.java:99) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.os.Looper.loop(Looper.java:123) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at android.app.ActivityThread.main(ActivityThread.java:4370) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at java.lang.reflect.Method.invokeNative(Native Method) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at java.lang.reflect.Method.invoke(Method.java:521) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
    12-11 18:09:14.306: E/AndroidRuntime(926): at dalvik.system.NativeStart.main(Native Method) 
    12-11 18:09:14.597: D/dalvikvm(915): GC freed 1836 objects/141248 bytes in 161ms 
    12-11 18:09:14.657: W/ActivityManager(1233): Activity pause timeout for HistoryRecord{45b2f140 com.datumdroid.android.ocr.simple/.SimpleAndroidOCRActivity} 
    12-11 18:09:14.657: E/SemcCheckin(926): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump 
    12-11 18:09:14.657: W/ActivityManager(1233): Unable to start service Intent { act=com.sonyericsson.android.jcrashcatcher.action.BUGREPORT_AUTO cmp=com.sonyericsson.android.jcrashcatcher/.JCrashCatcherService (has extras) }: not found 
    12-11 18:09:14.667: I/Process(1233): Sending signal. PID: 926 SIG: 3 
    12-11 18:09:14.667: I/dalvikvm(926): threadid=7: reacting to signal 3 
    12-11 18:09:14.667: I/dalvikvm(926): Wrote stack trace to '/data/anr/traces.txt' 
    12-11 18:09:14.677: I/Process(926): Sending signal. PID: 926 SIG: 9 
    12-11 18:09:14.687: E/SemcCheckin(1704): Get Crash Level : java.io.FileNotFoundException: /data/semc-checkin/crashdump 

    12-11 18:12:30.927: E/AndroidRuntime(1009): Uncaught handler: thread main exiting due to uncaught exception 
    12-11 18:12:30.936: E/AndroidRuntime(1009): java.lang.ExceptionInInitializerError 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onPhotoTaken(SimpleAndroidOCRActivity.java:211) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at com.datumdroid.android.ocr.simple.SimpleAndroidOCRActivity.onActivityResult(SimpleAndroidOCRActivity.java:135) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.Activity.dispatchActivityResult(Activity.java:3835) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.ActivityThread.deliverResults(ActivityThread.java:3332) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.ActivityThread.handleSendResult(ActivityThread.java:3378) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.ActivityThread.access$2700(ActivityThread.java:123) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1900) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.os.Handler.dispatchMessage(Handler.java:99) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.os.Looper.loop(Looper.java:123) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at android.app.ActivityThread.main(ActivityThread.java:4370) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at java.lang.reflect.Method.invokeNative(Native Method) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at java.lang.reflect.Method.invoke(Method.java:521) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at dalvik.system.NativeStart.main(Native Method) 
    12-11 18:12:30.936: E/AndroidRuntime(1009): Caused by: java.lang.UnsatisfiedLinkError: Library lept not found 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at java.lang.Runtime.loadLibrary(Runtime.java:489) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at java.lang.System.loadLibrary(System.java:557) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47) 
    12-11 18:12:30.936: E/AndroidRuntime(1009):  ... 15 more 
    12-11 18:12:30.946: E/SemcCheckin(1009): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump 
+0

你應該添加一些代碼。堆棧跟蹤只會幫助不大。 – rekire

+0

@blob 1.請將代碼放入您的問題中,而不是回答。我將代碼合併爲下一次的建議。 2.你有沒有嘗試在第一行調用super.onCreate()? – WarrenFaith

回答

0

正如我所看到的,您沒有在您的SimpleChart(Bundle)方法中調用super.onCreate(savedInstanceState)SimpleAndroidOCRActivity

+0

是的,我起初自己教過我已經發布了上面的onCreate方法,你可以看到super.onCreate被稱爲t – blob