title: Error while rendering pdf using mupdf
body: <p>I am working on rendering pdf reader in my app using MUPDF reader.While rendering it throws nullpointer error.I have attached my code fully.I have the pdf in sdcard and checked whether sdcard is mountable.Do help me please</p>
  
  <p>Manifest.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.ebookr"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-permission
       android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="16" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
  
      &lt;activity android:name="com.artifex.mupdfdemo.MuPDFActivity" 
                android:label="@string/app_name"
                android:theme="@android:style/Theme.NoTitleBar"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;data android:mimeType="application/vnd.ms-xpsdocument"/&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;data android:mimeType="application/pdf"/&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;data android:mimeType="application/x-cbz"/&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;category android:name="android.intent.category.BROWSABLE"/&gt;
              &lt;data android:scheme="file"/&gt;
              &lt;data android:mimeType="*/*"/&gt;
              &lt;data android:pathPattern=".*\\.xps"/&gt;
              &lt;data android:host="*"/&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;category android:name="android.intent.category.BROWSABLE"/&gt;
              &lt;data android:scheme="file"/&gt;
              &lt;data android:mimeType="*/*"/&gt;
              &lt;data android:pathPattern=".*\\.pdf"/&gt;
              &lt;data android:host="*"/&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.VIEW"/&gt;
              &lt;category android:name="android.intent.category.DEFAULT"/&gt;
              &lt;category android:name="android.intent.category.BROWSABLE"/&gt;
              &lt;data android:scheme="file"/&gt;
              &lt;data android:mimeType="*/*"/&gt;
              &lt;data android:pathPattern=".*\\.cbz"/&gt;
              &lt;data android:host="*"/&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name="OutlineActivity"
                android:label="@string/outline_title"&gt;
      &lt;/activity&gt;
  
      &lt;activity
          android:name="com.example.ebookr.MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>   </p>
  
  <p>ManiActivity.java</p>
  
  <pre><code>package com.example.ebookr;
  
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.Environment;
  import android.app.Activity;
  import android.content.ActivityNotFoundException;
  import android.content.Intent;
  import android.content.res.AssetManager;
  import android.util.Log;
  import android.view.Menu;
  import com.artifex.mupdfdemo.*;
  
  public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      CopyAssetsbrochure(); 
  
      try
      {
      //Uri uri = Uri.parse("/sdcard/divya.pdf");
  
      String path = "/sdcard/divya.pdf";
      MuPDFActivity pdf = new MuPDFActivity(); 
      try {
      pdf.openFileInput(path);
      }
      catch(Exception e)
      {
          Log.e("in code",e.getMessage());
      }
  
      /*Intent intent = new Intent(getBaseContext(), MuPDFActivity.class);
  
      intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
      intent.setAction(Intent.ACTION_VIEW);
  
      intent.setData(uri);
  
      getBaseContext().startActivity(intent); */
      }
      catch (Exception e) {
          // TODO Auto-generated catch block
          StackTraceElement[] stack = e.getStackTrace();
          String StringTrace = "";
          String Trace = null;
          for(StackTraceElement line : stack)
          {
             Trace += line.toString();
          }
  
              Log.e("Soap",Trace);
  
          String err = (e.getMessage()==null)?"SD Card failed":e.getMessage();
          Log.e("sdcard-err2:",err);  
          e.getCause();
  
      } 
  
  
  
  }
  
  private void CopyAssetsbrochure() {
      AssetManager assetManager = getAssets();
      String state = Environment.getExternalStorageState();
      if (Environment.MEDIA_MOUNTED.equals(state)) {
          Log.d("Test", "sdcard mounted and writable");
      }
      else
      {
          Log.d("Test", "sdcard state: " + state);
      }
      String[] files = null;
      try 
      {
          files = assetManager.list("");
      } 
      catch (IOException e)
      {
          Log.e("tag", e.getMessage());
      }
      for(int i=0; i&lt;files.length; i++)
      {
          String fStr = files[i];
          if(fStr.equalsIgnoreCase("divya.pdf"))
          {
              InputStream in = null;
              OutputStream out = null;
              try 
              {
                in = assetManager.open(files[i]);
                out = new FileOutputStream("/sdcard/" + files[i]);
                copyFile(in, out);
                in.close();
                in = null;
                out.flush();
                out.close();
                out = null;
                break;
              } 
              catch(Exception e)
              {
                  Log.e("CopyAssests", e.getMessage());
              } 
          }
      }
  }
  
   private void copyFile(InputStream in, OutputStream out) throws IOException {
      byte[] buffer = new byte[1024];
      int read;
      while((read = in.read(buffer)) != -1){
        out.write(buffer, 0, read);
      }
  }
  
  
  @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;
  }
  
  }
  </code></pre>
  
  <p>LogCat:</p>
  
  <pre><code>07-07 11:22:49.689: W/Trace(2085): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:21.929: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:21.929: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:21.939: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0   
  07-07 11:23:22.310: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:22.365: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:23.279: D/Test(2189): sdcard mounted and writable
  07-07 11:23:24.631: E/Soap(2189): nullandroid.util.Log.println_native(Native                    Method)android.util.Log.e(Log.java:231)com.example.ebookr.MainActivity.onCreate(MainActivity.java:40)android.app.Activity.performCreate(Activity.java:5104)android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)android.app.ActivityThread.access$600(ActivityThread.java:141)android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)android.os.Handler.dispatchMessage(Handler.java:99)android.os.Looper.loop(Looper.java:137)android.app.ActivityThread.main(ActivityThread.java:5039)java.lang.reflect.Method.invokeNative(Native Method)java.lang.reflect.Method.invoke(Method.java:511)com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)dalvik.system.NativeStart.main(Native Method)
  07-07 11:23:24.631: E/sdcard-err2:(2189): println needs a message
  07-07 11:23:24.769: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:24.790: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:24.861: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:24.909: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.099: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.109: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.139: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.209: I/Choreographer(2189): Skipped 31 frames!  The application may be doing too much work on its main thread.
  07-07 11:23:25.249: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.249: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.269: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.269: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.279: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.279: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.299: D/gralloc_goldfish(2189): Emulator without GPU emulation detected.
  07-07 11:23:25.409: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  07-07 11:23:25.469: W/Trace(2189): Unexpected value from nativeGetEnabledTags: 0
  </code></pre>