引起:java.lang.NoClassDefFoundError:R $ styleable

时间:2016-06-15 09:40:27

标签: android gradle noclassdeffounderror

我正在将Eclipse项目迁移到gradle。迁移后,我在尝试检索attr时在自定义视图中面临NoClassDefFoundError

Caused by: java.lang.NoClassDefFoundError: com.myproject.task.R$styleable
com.myproject.task.widgets.TaskTextView.<init>(TaskTextView.java:24)
java.lang.reflect.Constructor.constructNative(Native Method) 
java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
android.view.LayoutInflater.createView(LayoutInflater.java:594) 
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
Com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity.setContentView(SlidingFragmentActivity.java:59)

这是我的自定义视图类

public class TaskTextView extends TextView {

    private TypedArray attrArray;

    public TaskTextView(Context context) {
        super(context);
    }

    public TaskTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        attrArray = context.obtainStyledAttributes(attrs, R.styleable.TaskTextViewAttr);// app crashes here

    }

    public TaskTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        attrArray = context.obtainStyledAttributes(attrs, R.styleable.TaskTextViewAttr);// app crashes here

    }

}

请帮帮我...

0 个答案:

没有答案