janheinrichmerker / material-intro

A simple material design app intro with cool animations and a fluent API.
https://jitpack.io/#com.heinrichreimer/material-intro
MIT License
1.74k stars 307 forks source link

I build slideshow, No error but app is not ruing in ADB. showing shome coused #280

Closed ejaki943 closed 4 years ago

ejaki943 commented 4 years ago

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.viewpager.widget.ViewPager.setAdapter(androidx.viewpager.widget.PagerAdapter)' on a null object reference at com.adworld.admin.myapplication.MainActivity.onCreate(MainActivity.java:30)

Java Coding:

package com.adworld.admin.myapplication;

import androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.viewpager.widget.ViewPager;

import android.os.Bundle; import android.view.MenuItem; import android.widget.FrameLayout;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {

ViewPager viewPager;

BottomNavigationView bottomNavigationView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    viewPager = (ViewPager)findViewById(R.id.myViewPager);

    ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(this);

    viewPager.setAdapter(viewPagerAdapter);
janheinrichmerker commented 4 years ago

The activity class you posted does not include any material-intro code, neither does the stacktrace.

Nonetheless, it seems as if Android could not find your view pager. Thus the NullPointerException. Please check, if the view pager (R.id.myViewPager) does exist in your layout file.

PS: On GitHub, you can format code with backticks:

```
code
```
janheinrichmerker commented 4 years ago

Closing the issue since it's unrelated to this library.