ErlAl ErlAl - 1 month ago 17
Android Question

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager

I'm getting an error when I'm running my project. I was just following this tutorial and used it in my project.

my code which is exactly alike in the tutorial

public class MainEventActivity extends AppCompatActivity {

private Toolbar toolbar;
private TabLayout tabLayout;
private ViewPager viewPager;

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

toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);

tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}

private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new OneFragment(), "ONE");
adapter.addFragment(new TwoFragment(), "TWO");
adapter.addFragment(new ThreeFragment(), "THREE");
viewPager.setAdapter(adapter);
}

class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();

public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}

@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}

@Override
public int getCount() {
return mFragmentList.size();
}

public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}

@Override
public CharSequence getPageTitle(int position) {
return mFragmentTitleList.get(position);
}
}


Im calling the MainEventActivity like this :

btnNext.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
Intent i = new Intent(MainActivity.this, MainEventActivity.class);
startActivity(i);
finish();
}
});


my error log:

12-01 08:00:29.903 22530-22530/com.erlawkward.albarol.eventlocatorapp
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: android.support.v7.internal.widget.TintManager
at android.support.design.widget.TabLayout$TabView.<init>(TabLayout.java:1145)
at android.support.design.widget.TabLayout.createTabView(TabLayout.java:635)
at android.support.design.widget.TabLayout.addTabView(TabLayout.java:669)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:365)
at android.support.design.widget.TabLayout.addTab(TabLayout.java:340)
at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:624)
at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:595)
at com.erlawkward.albarol.eventlocatorapp.activity.activity.MainEventActivity.onCreate(MainEventActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)


error in this line:

tabLayout.setupWithViewPager(viewPager);

Answer

All the support libraries have to be the same version. Try changing either appcompat-v7 and support-v4 to 23.0.1 or design to 23.1.1

Comments