title: App Crash using yalantis uCrop Library
body: <p>After Import <a href="https://github.com/Yalantis/uCrop" rel="nofollow">Yalantis uCrop</a> to Project, when i want to Crop Image And Call Library Methods LogCat shows <code>NullPointerException</code>
  Crop Method is : </p>
  
  <pre><code>    private void doCrop(){
      LTH.dLog(PHOTO_TAG, "Do Crop -&gt; PICK FROM FILE : " + getRealPathFromURI(mImageCaptureUri));
      UCrop.of(mImageCaptureUri, mImageCaptureUri/*getUriFromPath()*/)
              .withAspectRatio(16, 9)
              .withMaxResultSize(UI.width, UI.height)
              .start(PurchaseActivity.this);
  }
  private String getRealPathFromURI(Uri contentURI) {
      String path;
      Cursor cursor = getContentResolver()
              .query(contentURI, null, null, null, null);
      if (cursor == null)
          path=contentURI.getPath();
  
      else {
          cursor.moveToFirst();
          int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA);
          path=cursor.getString(idx);
  
      }
      if(cursor!=null)
          cursor.close();
      return path;
  }
  private Uri getUriFromPath(){
      String DIR_SDCARD = Environment.getExternalStorageDirectory().getAbsolutePath();
      String DIR_APP = DIR_SDCARD + "/Android/data/" + App.getContext().getPackageName() + "/"+App.getString(App.getContext(), R.string.dir_app)+"/";
      String DIR_CAPTURE = DIR_APP + App.getString(App.getContext(), R.string.dir_capture);
      new File(DIR_APP).mkdirs();
      new File(DIR_APP+DIR_CAPTURE).mkdirs();
      final String IMG_DIR = DIR_APP+DIR_CAPTURE+"/";
      Uri pathUri = Uri.fromFile(new File(IMG_DIR));
      LTH.dLog(PHOTO_TAG, "get Uri From Path -&gt; Uri : "+getRealPathFromURI(pathUri)+" \t "+pathUri);
      return pathUri;
  }
  </code></pre>
  
  <p>Error Log Is :</p>
  
  <pre><code>03-06 16:46:20.784  21117-21117/com.emaarit.app.erbgroup E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.emaarit.app.erbgroup, PID: 21117
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.emaarit.app.erbgroup/com.yalantis.ucrop.UCropActivity}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
          at android.app.ActivityThread.access$800(ActivityThread.java:151)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
          at android.os.Handler.dispatchMessage(Handler.java:110)
          at android.os.Looper.loop(Looper.java:193)
          at android.app.ActivityThread.main(ActivityThread.java:5333)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
          at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
          at com.yalantis.ucrop.UCropActivity.setupViews(UCropActivity.java:235)
          at com.yalantis.ucrop.UCropActivity.onCreate(UCropActivity.java:99)
          at android.app.Activity.performCreate(Activity.java:5343)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
  </code></pre>
  
  <p>So I Dont Know How To Fix It</p>