2014-07-29 4 views
0

Я разрабатываю приложение для распознавания изображений, и у меня есть образец кода для работы. В моем коде, когда я выполнил, появляется ошибка. Я даю свой код ниже ... и LogCat кто может мне помочь ..Ошибка распознавания изображения Android

LogCat

07-29 02:48:30.533: E/AndroidRuntime(1332): FATAL EXCEPTION: main 
07-29 02:48:30.533: E/AndroidRuntime(1332): Process: com.example.therefore, PID: 1332 
07-29 02:48:30.533: E/AndroidRuntime(1332): java.lang.NoClassDefFoundError: com.example.therefore.ARFromCraftARActivity 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at com.example.therefore.LaunchersActivity.onClick(LaunchersActivity.java:99) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.view.View.performClick(View.java:4438) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.view.View$PerformClick.run(View.java:18422) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.os.Handler.handleCallback(Handler.java:733) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.os.Handler.dispatchMessage(Handler.java:95) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.os.Looper.loop(Looper.java:136) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at android.app.ActivityThread.main(ActivityThread.java:5017) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at java.lang.reflect.Method.invokeNative(Native Method) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at java.lang.reflect.Method.invoke(Method.java:515) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
07-29 02:48:30.533: E/AndroidRuntime(1332):  at dalvik.system.NativeStart.main(Native Method) 

LauncherActivity

public class LaunchersActivity extends Activity implements OnClickListener { 

    // Howto links 
    private TextView mHowToLink; 
    private LinearLayout mAboutArProgrammatically; 
    private LinearLayout mAboutArFromCraftAR; 
    private LinearLayout mAboutRecognitionOnly; 

    // Launch example links 
    private LinearLayout mArProgrammatically; 
    private LinearLayout mArFromCraftAR; 
    private LinearLayout mRecognitionOnly; 

    // Bottom links 
    private ImageButton mButtonCatchoom; 
    private Button mButtonSignUp; 


    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.activity_launchers); 

     // Setup howto links 
     mHowToLink = (TextView)findViewById(R.id.howto_link); 
     mHowToLink.setClickable(true); 
     mHowToLink.setOnClickListener(this); 
     mAboutArProgrammatically = (LinearLayout)findViewById(R.id.howto_link_ar_programmatically); 
     mAboutArProgrammatically.setClickable(true); 
     mAboutArProgrammatically.setOnClickListener(this); 
     mAboutArFromCraftAR = (LinearLayout)findViewById(R.id.howto_link_ar_from_craftar); 
     mAboutArFromCraftAR.setClickable(true); 
     mAboutArFromCraftAR.setOnClickListener(this); 
     mAboutRecognitionOnly = (LinearLayout)findViewById(R.id.howto_link_recognition_only); 
     mAboutRecognitionOnly.setClickable(true); 
     mAboutRecognitionOnly.setOnClickListener(this); 

     // Setup example links 
     mArProgrammatically = (LinearLayout)findViewById(R.id.play_ar_programmatically); 
     mArProgrammatically.setClickable(true); 
     mArProgrammatically.setOnClickListener(this); 
     mArFromCraftAR = (LinearLayout)findViewById(R.id.play_ar_from_craftar); 
     mArFromCraftAR.setClickable(true); 
     mArFromCraftAR.setOnClickListener(this); 
     mRecognitionOnly = (LinearLayout)findViewById(R.id.play_recognition_only); 
     mRecognitionOnly.setClickable(true); 
     mRecognitionOnly.setOnClickListener(this); 


     // Setup bottom Links 
     mButtonCatchoom = (ImageButton)findViewById(R.id.imageButton_logo); 
     mButtonCatchoom.setOnClickListener(this); 
     mButtonSignUp = (Button)findViewById(R.id.button_signUp); 
     mButtonSignUp.setOnClickListener(this); 
    } 

    @Override 
    public void onClick(View v) { 

     // Clicked on title or howto links 
     Intent launchHowto = null; 
     if (v == mHowToLink) { 
      launchHowto = new Intent(this, HowToActivity.class); 
      launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto); 
     } else if (v == mAboutArProgrammatically) { 
      launchHowto = new Intent(this, HowToActivity.class); 
      launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_ar_programmatically); 
     } else if (v == mAboutArFromCraftAR) { 
      launchHowto = new Intent(this, HowToActivity.class); 
      launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_ar_from_craftar); 
     } else if (v == mAboutRecognitionOnly) { 
      launchHowto = new Intent(this, HowToActivity.class); 
      launchHowto.putExtra(HowToActivity.HOWTO_LAYOUT_EXTRA, R.layout.activity_howto_recognition_only); 
     } 
     if (launchHowto != null) { 
      startActivity(launchHowto); 
      return; 
     } 

     // Clicked on play links 
     Intent playExampleIntent = null; 
     if (v == mArProgrammatically) { 
      playExampleIntent = new Intent(this, ARProgrammaticallyActivity.class); 
     } else if (v == mArFromCraftAR) { 
      playExampleIntent = new Intent(this, ARFromCraftARActivity.class); 
     } else if (v == mRecognitionOnly) { 
      playExampleIntent = new Intent(this, RecognitionOnlyActivity.class); 

     } 
     if (playExampleIntent != null) 
     { 
      startActivity(playExampleIntent); 
      return; 
     } 


     // Clicked on bottom links 
     if (v == mButtonCatchoom || v == mButtonSignUp) { 
      // mButtonCatchoom 
      String url = "http://catchoom.com/product/?utm_source=CraftARExamplesApp&utm_medium=Android&utm_campaign=HelpWithAPI"; 
      if (v == mButtonSignUp) { 
       url = "https://crs.catchoom.com/try-free?utm_source=CraftARExamplesApp&utm_medium=Android&utm_campaign=HelpWithAPI"; 
      } 

      Intent launchWebView = new Intent(this, WebActivity.class); 
      launchWebView.putExtra(WebActivity.WEB_ACTIVITY_URL, url); 
      startActivity(launchWebView);   
      return; 
     } 
    } 

} 

ARFromCraftActivity

public class ARFromCraftARActivity extends CatchoomActivity implements CatchoomResponseHandler,CatchoomImageHandler { 

    private final String TAG = "CatchoomTrackingExample"; 
    private final static String COLLECTION_TOKEN="craftarexamples1"; 

    private View mScanningLayout; 

    CatchoomCamera mCamera; 

    CatchoomCloudRecognition mCloudRecognition; 
    CatchoomTracking mCatchoomTracking; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
    } 

    @Override 
    public void onPostCreate() { 

     View mainLayout= (View) getLayoutInflater().inflate(R.layout.activity_ar_programmatically_ar_from_craftar, null); 
     CatchoomCameraView cameraView = (CatchoomCameraView) mainLayout.findViewById(R.id.camera_preview); 
     super.setCameraView(cameraView); 
     setContentView(mainLayout); 

     mScanningLayout = findViewById(R.id.layout_scanning); 


     //Initialize the SDK. From this SDK, you will be able to retrieve the necessary modules to use the SDK (camera, tracking, and cloud-recgnition) 
     CatchoomSDK.init(getApplicationContext(),this); 

     //Get the camera to be able to do single-shot (if you just use finder-mode, this is not necessary) 
     mCamera= CatchoomSDK.getCamera(); 
     mCamera.setImageHandler(this); //Tell the camera who will receive the image after takePicture() 

     //Setup the finder-mode: Note! PRESERVE THE ORDER OF THIS CALLS 
     mCloudRecognition= CatchoomSDK.getCloudRecognition();//Obtain the cloud recognition module 
     mCloudRecognition.setResponseHandler(this); //Tell the cloud recognition who will receive the responses from the cloud 
     mCloudRecognition.setCollectionToken(COLLECTION_TOKEN); //Tell the cloud-recognition which token to use from the finder mode 



     //Start finder mode 
     mCloudRecognition.startFinding(); 

     //Obtain the tracking module 
     mCatchoomTracking = CatchoomSDK.getTracking(); 

     mCloudRecognition.connect(COLLECTION_TOKEN); 

    } 

    @Override 
    public void searchCompleted(ArrayList<CatchoomCloudRecognitionItem> results) { 
     if(results.size()==0){ 
     }else{ 
      CatchoomCloudRecognitionItem item = results.get(0); 
      if (item.isAR()) { 
       // Stop Finding 
       mCloudRecognition.stopFinding(); 

       // Cast the found item to an AR item 
       CatchoomARItem myARItem = (CatchoomARItem)item; 

       // Add content to the tracking SDK and start AR experience 
       mCatchoomTracking.addItem(myARItem); 
       mCatchoomTracking.startTracking(); 

       mScanningLayout.setVisibility(View.GONE); 
      } 

     } 
    } 

    @Override 
    public void connectCompleted(){ 
     Log.i(TAG,"Collection token is valid"); 
    } 

    @Override 
    public void requestFailedResponse(int requestCode, 
      CatchoomCloudRecognitionError responseError) { 
     Log.d(TAG,"requestFailedResponse"); 

    } 

    //Callback received for SINGLE-SHOT only (after takePicture). 
    @Override 
    public void requestImageReceived(CatchoomImage image) { 
     mCloudRecognition.searchWithImage(COLLECTION_TOKEN,image); 
    } 
    @Override 
    public void requestImageError(String error) { 
     //Take picture failed 
    } 



} 

Image

+0

Как видите, проблема исходит из этой строки: 'playExampleIntent = new Intent (это, ARFromCraftARActivity.class);', проблема не в том, что класс не может быть найден, но, вероятно, к ошибке при построении A Объект RFromCraftARActivity (не могли бы вы дать нам конструктор и статический блок (если таковые имеются) этого класса) – ex0ns

+0

Я дал ARFromCRAftARActivity, ... пожалуйста, проверьте – Jocheved

ответ

0

Ошибка ClassNotFoundException это означает, компилятор не может найти свой ARFromCraftARActivity.java файл класса

так что вам нужно упомянуть этот класс совершенно, как в моем доперли вы используете библиотеку для этого проекта, если да, то следуйте ниже шаг, чтобы устранить ошибку «класс не найден исключение»

1) нажмите правой кнопкой мыши на проекте

2) свойства GOTO

3) Гото ява путь сборки

4) Порядок Гото и экспорта Вкладка

5) проверить в библиотеке, которые вы включаете в свой проект

6) нажмите кнопку ОК применить изменения и компиляция вашего кода

+0

Привет. Не могли бы вы проверить мой скриншот, я отредактировал с моим вопросом только теперь ... В этом я проверил все библиотеки .. может у PLS проверить, правильно это или нет .. – Jocheved

+0

да ур на правильном пути проверить все флажки и компилировать код d –

+0

Нет ... теперь тоже такая же ошибка – Jocheved

Смежные вопросы