Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:18:11+00:00 2026-05-27T00:18:11+00:00

public class EpubReaderMainActivity extends Activity { /** Called when the activity is first created.

  • 0
    public class EpubReaderMainActivity extends Activity {
    /** Called when the activity is first created. */



    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main );
        TextView tv = (TextView)findViewById(R.id.text);

        AssetManager am = getAssets();

        try{
            InputStream bookData = am.open("books/bookTest.epub");
            Book book = (new EpubReader()).readEpub(bookData);          
            Log.i("epublib", "author(s): " + book.getMetadata().getAuthors());
            Log.i("epublib", "title: " + book.getTitle());
            Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage()
                      .getInputStream());
            Log.i("epublib", "Coverimage is " + coverImage.getWidth() + " by "
                      + coverImage.getHeight() + " pixels");
            logTableOfContents(book.getTableOfContents().getTocReferences(), 0);

        }
        catch (IOException e) {
            // TODO: handle exception
            e.printStackTrace();
        }
        try{
            // read epub file
            EpubReader epubReader = new EpubReader();
            Book book = epubReader.readEpub(new FileInputStream("mybook.epub"));

            // print the first title
            List<String> titles = book.getMetadata().getTitles();
            String a = ("book title:" + (titles.isEmpty() ? "book has no title" : titles.get(0)));
            tv.setText(a);
        }
        catch (IOException e) {
            // TODO: handle exception
            e.printStackTrace();
        }

    }

    private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
        // TODO Auto-generated method stub
        if (tocReferences == null) {
              return;
            }
            for (TOCReference tocReference : tocReferences) {
              StringBuilder tocString = new StringBuilder();
              for (int i = 0; i < depth; i++) {
                tocString.append("\t");
              }
              tocString.append(tocReference.getTitle());
              Log.i("epublib", tocString.toString());

              logTableOfContents(tocReference.getChildren(), depth + 1);
            }

        }
    }

Stacktrace

    11-21 10:51:19.570: I/AndroidLoggerFactory(325): Logger name 'nl.siegmann.epublib.epub.EpubReader' exceeds maximum length of 23 characters, using 'n*.s*.e*.e*.EpubReader' instead.
    11-21 10:51:19.780: D/dalvikvm(325): GC_CONCURRENT freed 1136K, 56% free 2984K/6727K, external 2002K/2137K, paused 3ms+3ms
    11-21 10:51:19.790: I/AndroidLoggerFactory(325): Logger name 'nl.siegmann.epublib.epub.EpubProcessorSupport' exceeds maximum length of 23 characters, using 'n*.s*.e*.e*.EpubProces*' instead.
    11-21 10:51:19.830: I/AndroidLoggerFactory(325): Logger name 'nl.siegmann.epublib.epub.PackageDocumentReader' exceeds maximum length of 23 characters, using 'n*.s*.e*.e*.PackageDoc*' instead.
    11-21 10:51:19.929: I/AndroidLoggerFactory(325): Logger name 'nl.siegmann.epublib.epub.NCXDocument' exceeds maximum length of 23 characters, using 'n*.s*.e*.e*.NCXDocument' instead.
    11-21 10:51:19.980: I/epublib(325): author(s): [Haynes, Carrie James]
    11-21 10:51:19.980: I/epublib(325): title: Whispers of a Legend - Part One - Shadows of the Past
    11-21 10:51:19.980: D/AndroidRuntime(325): Shutting down VM
    11-21 10:51:19.980: W/dalvikvm(325): threadid=1: thread exiting with uncaught exception (group=0x40015560)
    11-21 10:51:19.990: E/AndroidRuntime(325): FATAL EXCEPTION: main
    11-21 10:51:19.990: E/AndroidRuntime(325): java.lang.RuntimeException: Unable to start activity ComponentInfo{epub.reader/epub.reader.EpubReaderMainActivity}: java.lang.NullPointerException
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.os.Handler.dispatchMessage(Handler.java:99)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.os.Looper.loop(Looper.java:123)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at java.lang.reflect.Method.invokeNative(Native Method)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at java.lang.reflect.Method.invoke(Method.java:507)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at dalvik.system.NativeStart.main(Native Method)
    11-21 10:51:19.990: E/AndroidRuntime(325): Caused by: java.lang.NullPointerException
    11-21 10:51:19.990: E/AndroidRuntime(325):  at epub.reader.EpubReaderMainActivity.onCreate(EpubReaderMainActivity.java:43)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-21 10:51:19.990: E/AndroidRuntime(325):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    11-21 10:51:19.990: E/AndroidRuntime(325):  ... 11 more

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="epub.reader"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".EpubReaderMainActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

I have been trying for a while but I am stuck.
Here is what I tried I checked the Epublib packages if there is any requirement of a permission in order to run the activity. What this activity does is log in the .epub file and read just the first title since I am testing out their code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:18:12+00:00Added an answer on May 27, 2026 at 12:18 am

    Study the trace carefully: towards the bottom you have

    11-21 10:51:19.990: E/AndroidRuntime(325): Caused by: java.lang.NullPointerException
    11-21 10:51:19.990: E/AndroidRuntime(325):  at epub.reader.EpubReaderMainActivity.onCreate(EpubReaderMainActivity.java:43)
    

    Check your onCreate method, line 43 in the activity class file, whichever that is 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Offer_Popup extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.offer_popup); //newly
public class SettingsActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*
public class Browser1Activity extends Activity { TextView url; WebView ourBrow; @Override protected void onCreate(Bundle
public class TestConnection extends Activity { /** Called when the activity is first created.
public class Boards : TabActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Tab);
public class HomeActivity extends Activity{ // public ArrayList<User> users1 = new ArrayList<User>(); @Override public
public class CustomEditor : Editor { protected override void Render(HtmlTextWriter writer) { Toolbar topToolbar
public class TextBoxDerived : System.Web.UI.WebControls.TextBox { protected override void OnLoad(EventArgs e) { this.Controls.Add(new LiteralControl(Hello));
public class ReportView extends JFrame { Connection con=null; void showReport() throws SQLException, ClassNotFoundException, JRException
public class WordDisplay extends Activity { private int level; private int group; private int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.