Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

super.OnCreate NPE error #122

Closed
gau4sar opened this issue Aug 31, 2016 · 7 comments
Closed

super.OnCreate NPE error #122

gau4sar opened this issue Aug 31, 2016 · 7 comments
Assignees
Labels
Milestone

Comments

@gau4sar
Copy link

gau4sar commented Aug 31, 2016

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.heinrichreimersoftware.materialintro.view.FadeableViewPager.setAdapter(android.support.v4.view.PagerAdapter)' on a null object reference
                                                                                 at com.heinrichreimersoftware.materialintro.app.IntroActivity.findViews(IntroActivity.java:282)
                                                                                 at com.heinrichreimersoftware.materialintro.app.IntroActivity.onCreate(IntroActivity.java:174)
                                                                                 at Method) 

This is my activity

public class AppIntroActivity extends IntroActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setFullscreen(true);

        addSlide(new SimpleSlide.Builder()
            .title(R.string.welcome_text)
            .description(R.string.description)
            .image(R.drawable.finalroadlogo)
            .background(R.color.LAPIS_LAZULI)
            .backgroundDark(R.color.btn_pressed_dark_blue)
            .build());

        addSlide(new SimpleSlide.Builder()
            .title(R.string.welcome_text)
            .description(R.string.description)
            .image(R.drawable.finalroadlogo)
            .background(R.color.LAPIS_LAZULI)
            .backgroundDark(R.color.btn_pressed_dark_blue)
            .build());
    }
}
@heinrichreimer heinrichreimer added this to the Release 1.5.8 milestone Aug 31, 2016
@heinrichreimer heinrichreimer self-assigned this Aug 31, 2016
@heinrichreimer
Copy link
Owner

Did you call setContentView() or did you overrride R.layout.activity_intro?

@gau4sar
Copy link
Author

gau4sar commented Aug 31, 2016

The code is as it is . I have not called setContentView() neither have i overriden R.layout.activity_intro

@gau4sar
Copy link
Author

gau4sar commented Sep 1, 2016

@heinrichreimer did you get around to solving this issue ?

@heinrichreimer
Copy link
Owner

The error message says that the activity can't find the ViewPager in the content view. There are two reasons for this:

  1. Someone called setContentView() with another layout resource
  2. Someone has overriden the library's layout resource R.layout.activity_intro

To help me understand the issue better please use the hierachy viewer from the android development kit and post a screenshot of the layout hierachy.

@heinrichreimer
Copy link
Owner

FYI I can't reproduce this issue on either my phone or the emulator. Are you using any framework or stuff that hacks in your Android resources?

@heinrichreimer
Copy link
Owner

Closing due to inactivity. Will reopen this if you provide more information on how to reproduce this issue.

@suomi35
Copy link

suomi35 commented Nov 14, 2016

Heinrich, I had the same issue. The cause ended up being that I had another layout named R.layout.activity_intro, as you suggested about. Once I got rid of that file everything worked fine.
Perhaps you could add a more unique naming convention to the library resources, like R.layout.hrs.activity_intro or something...or just add a note in the README ;)
Thanks for a great library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants