Reputation: 637
Everything was working fine until i updated my gradle file and now my tablayout is crashing due to error:
Java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/widget/TintManager; at android.support.design.widget.TabLayout$TabView.(TabLayout.java:1185) at android.support.design.widget.TabLayout.createTabView(TabLayout.java:656) at android.support.design.widget.TabLayout.addTabView(TabLayout.java:695) at android.support.design.widget.TabLayout.addTab(TabLayout.java:386) at android.support.design.widget.TabLayout.addTab(TabLayout.java:361) at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:645) at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:616) at com.example.ScrollableTabsActivity.onCreate(ScrollableTabsActivity.java:307) at android.app.Activity.performCreate(Activity.java:6033) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2397) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1310) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5268) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.TintManager" on path: DexPathList[[zip file "/data/app/com.example-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.support.design.widget.TabLayout$TabView.(TabLayout.java:1185) at android.support.design.widget.TabLayout.createTabView(TabLayout.java:656) at android.support.design.widget.TabLayout.addTabView(TabLayout.java:695) at android.support.design.widget.TabLayout.addTab(TabLayout.java:386) at android.support.design.widget.TabLayout.addTab(TabLayout.java:361) at android.support.design.widget.TabLayout.setTabsFromPagerAdapter(TabLayout.java:645) at android.support.design.widget.TabLayout.setupWithViewPager(TabLayout.java:616)
Here is my gradle
file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.mcxiaoke.volley:library:1.0.+@aar'
compile 'com.github.hotchemi:stringpicker:0.0.2'
compile files('libs/devsmartlib.jar')
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile project(':lib')
}
Please help me where am wrong
Upvotes: 14
Views: 12542
Reputation: 171
You first create a new activity but not empty activity and choose tabed activity ,then do as I did..
step 1 : create three fragment activity first delete everything from each fragment activity and write this code to each activity
package com.yourpakagename.tabedactivity;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class layout1 extends Fragment {
public layout1() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_layout12, container, false);
//changes in each activity-->R.layout.fragment_layout_name<----
}
}
step 2 : and finally in your tabbed activity we dont need this two functions
public static class PlaceholderFragment extends Fragment {
private static final String ARG_SECTION_NUMBER = "section_number";
public PlaceholderFragment() {
}
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
step 3: and finally change your sectionpageradapter function with this code thats it -->
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
//delete return PlaceholderFragment.newInstance(position + 1);
switch (position)
{
case 0:
return new layout1();
case 1:
return new layout2();
case 2:
return new layout3();
default:
return new layout1();
}
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
}
Upvotes: -1
Reputation: 38223
All support libs must have the same version. 23.2.1 or 23.1.1 or whatever but you can't mix versions.
ext.supportLibVersion = "23.2.1"
// design includes recyclerview-v7 and appcompat-v7, which includes support-v4
compile "com.android.support:design:$supportLibVersion"
compile "com.android.support:cardview-v7:$supportLibVersion"
Upvotes: 9
Reputation: 637
changing dependencies did the trick , just added com.android.support:support-v4:23.2.0 and updated build tools version to 23.0.2
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
I dont know why some people marked my question as negative, anyways this might help someone
Upvotes: 38