astuetz / PagerSlidingTabStrip

An interactive indicator to navigate between the different pages of a ViewPager
139 stars 44 forks source link

NoClassDefFoundError: com.astuetz.pagerslidingtabstrip.R$drawable #232

Closed piyush92 closed 9 years ago

piyush92 commented 9 years ago

Hi,

I'm facing an issue with the module. I'm try to add a MixPanel module into my project which already contains PagerSlidingTabStrip, but after adding the MixPanel module and compiling. The Application crashes at runtime with following errors. Please help me out. Thanks in advance.

07-06 12:18:21.843  16571-16571/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.mypoolin/com.app.mypoolin.Main.MainActivity}: android.view.InflateException: Binary XML file line #30: Error inflating class com.astuetz.PagerSlidingTabStrip
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2070)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
            at android.app.ActivityThread.access$600(ActivityThread.java:134)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4830)
            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:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.astuetz.PagerSlidingTabStrip
            at android.view.LayoutInflater.createView(LayoutInflater.java:613)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at com.app.mypoolin.Main.MainActivity.onCreate(MainActivity.java:134)
            at android.app.Activity.performCreate(Activity.java:5021)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
            at android.app.ActivityThread.access$600(ActivityThread.java:134)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4830)
            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:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
            at android.view.LayoutInflater.createView(LayoutInflater.java:587)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at com.app.mypoolin.Main.MainActivity.onCreate(MainActivity.java:134)
            at android.app.Activity.performCreate(Activity.java:5021)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
            at android.app.ActivityThread.access$600(ActivityThread.java:134)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4830)
            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:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NoClassDefFoundError: com.astuetz.pagerslidingtabstrip.R$drawable
            at com.astuetz.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:102)
            at com.astuetz.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:115)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
            at android.view.LayoutInflater.createView(LayoutInflater.java:587)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
            at com.app.mypoolin.Main.MainActivity.onCreate(MainActivity.java:134)
            at android.app.Activity.performCreate(Activity.java:5021)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2095)
            at android.app.ActivityThread.access$600(ActivityThread.java:134)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4830)
            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:789)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
            at dalvik.system.NativeStart.main(Native Method)

This is the my gradle.build file.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.app.mypoolin"
        minSdkVersion 14
        targetSdkVersion 16
        versionCode 12
        versionName "1.03"
        multiDexEnabled = true
    }
    buildTypes {
        release {

            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            shrinkResources true
        }
        debug{
            debuggable false
        }
    }

    repositories{

        jcenter()

        maven {
            url 'http://dl.bintray.com/amulyakhare/maven'
        }

        flatDir
                {
                    dirs 'libs'
                }

     }

    dexOptions {
        javaMaxHeapSize "4g"
    }

}

dependencies {
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:appcompat-v7:21.+'
    compile project(':pull-to-refresh')  // to be replaced with secure version
    compile files('libs/commons-codec-1.10.jar')
    compile 'com.android.support:support-v13:20.0.0'
    compile project(':swipemenulistview')
    compile files('../jars/quickblox-android-sdk-core-2.2.jar')
    compile files('../jars/quickblox-android-sdk-content-2.2.jar')
    compile files('../jars/quickblox-android-sdk-chat-2.2.jar')
    // compile 'com.google.android.gms:play-services:7.0.0'
    compile 'com.facebook.android:facebook-android-sdk:4.0.0'
    compile 'com.android.support:recyclerview-v7:21.0.+'
    compile 'com.mixpanel.android:mixpanel-android:4.6.0'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    // compile 'com.jpardogo.materialtabstrip:library:1.0.9'
    // compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
    compile files('libs/gson-2.2.2.jar')
    compile files('libs/devsmartlib.jar')
    // compile project(':bugclipper-android-sdk')
    compile 'com.android.support:multidex:1.0.0'   // to be checked ?
    // compile(name: 'bugclipper-android-sdk', ext: 'aar')
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    //compile project(':spinnerwheel')
    compile 'com.android.support:support-v4:21.0.+'  // to be checked

    compile project(':pagerslidingtabstrip')

    compile project(':pgsdk')
}

Following is the activity_main.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:com.astuetz.PagerSlidingTabStrip="http://schemas.android.com/apk/res-auto"
    xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".Fragments.Home">

          <include
              android:id="@+id/tool_bar"
              layout="@layout/tool_bar">
          </include>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/tab_color"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/tabs">

    </RelativeLayout>

    <com.astuetz.PagerSlidingTabStrip
              android:id="@+id/tabs"
              android:layout_width="match_parent"
              android:layout_below="@+id/tool_bar"
              android:layout_height="48dip"
              com.astuetz.PagerSlidingTabStrip:pstsIndicatorColor="@color/brand_blue"
              com.astuetz.PagerSlidingTabStrip:pstsTextAllCaps="false"
              com.astuetz.PagerSlidingTabStrip:pstsIndicatorHeight="3dp"
              />

            <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/tabs"
                >
            </android.support.v4.view.ViewPager>

    <!--<RelativeLayout
        android:id="@+id/plusFloatLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:background="@drawable/oval_orange"
        android:clickable="true"
        android:padding="5dp">

        <ImageView
            android:id="@+id/imageButtonChat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/plus"
            android:layout_centerInParent="true"
            />

    </RelativeLayout>-->
    <ImageButton
        android:id="@+id/plusFloatButton"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/plus_big"
        android:background="@drawable/float_background"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="10dp"
        android:padding="5dp"
        />

    <com.app.mypoolin.Objects.MyButton
        android:id="@+id/buttonVerify"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:background="@color/brand_orange"
        android:textColor="@color/white"
        android:text="Enter OTP manually or Re-enter Phone number"
        android:layout_alignParentBottom="true"
        />

   </RelativeLayout>
rscott78 commented 9 years ago

I've also got the same issue. @piyush92 - Did you get it fixed?

piyush92 commented 9 years ago

Yup, I did! turned out I enabled mutlidexing but some lines of code were missing from application class. I had to override a method

@Override
protected void attachBaseContext(Context base) {
  super.attachBaseContext(base);
  MultiDex.install(this);
}

I referred to this link http://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library