二进制文件-NoClassDefFoundError:... R $ styleable circlepageIndicator.java

时间:2015-10-03 07:09:39

标签: android exception android-viewpager android-inflate

kitkat 设备中的

错误,而不是更高版本的android。 更改gradle文件后。用于圆形寻呼机指示器的库。 https://github.com/JakeWharton/ViewPagerIndicator

依赖项{classpath' com.android.tools.build:gradle:1.0.0'} 依赖关系{classpath' com.android.tools.build:gradle:1.3.0'}

错误是:

 Binary XML file line #43: Error inflating class com.viewpagerindicator.CirclePageIndicator
 Caused by: java.lang.NoClassDefFoundError: com.app.skedule.R$styleable
10-03 12:29:47.501 28314-28314/? E/AndroidRuntime:     
 at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:93)
10-03 12:29:47.501 28314-28314/? E/AndroidRuntime:     
 at com.viewpagerindicator.CirclePageIndicator.<init>(CirclePageIndicator.java:74)
 CirclePageIndicator.java(inside my project->java->viewpagerindicator package)

package com.viewpagerindicator;

public class CirclePageIndicator extends View implements PageIndicator {
private static final int INVALID_POINTER = -1;

private float mRadius;
private final Paint mPaintPageFill = new Paint(ANTI_ALIAS_FLAG);
private final Paint mPaintStroke = new Paint(ANTI_ALIAS_FLAG);
private final Paint mPaintFill = new Paint(ANTI_ALIAS_FLAG);
private ViewPager mViewPager;
private ViewPager.OnPageChangeListener mListener;
private int mCurrentPage;
private int mSnapPage;
private float mPageOffset;
private int mScrollState;
private int mOrientation;
private boolean mCentered;
private boolean mSnap;

private int mTouchSlop;
private float mLastMotionX = -1;
private int mActivePointerId = INVALID_POINTER;
private boolean mIsDragging;


public CirclePageIndicator(Context context) {
    this(context, null);
}

public CirclePageIndicator(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.vpiCirclePageIndicatorStyle);
}

public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (isInEditMode()) return;

    //Load defaults from resources
    final Resources res = getResources();
    final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
    final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
    final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
    final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
    final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
    final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
    final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
    final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);

    //Retrieve styles attributes
  `TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);  //Error here`  

1 个答案:

答案 0 :(得分:0)

参考此Link

添加了

dependencies { compile 'com.android.support:multidex:1.0.0'} defaultConfig { multiDexEnabled true}

public class MyApplication extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}`

终于得到了解决方案。