请帮我解决这个问题,我被困在这里,我的应用程序适用于更高版本的设备,MOGO G3和Moto XPlay,但是当我在具有较低版本(16)的设备上进行测试时,它给出了我的错误,即NoClassDefFoundError。 / p>
这是我的sdk配置:
minSdkVersion 16 targetSdkVersion 22
这是android在运行时无法找到的类:
public class CategoryParcel implements Parcelable{
private Long id;
private int icon;
private int category_resource;
private String categories;
private String note;
private Integer price;
private Integer quantity;
private String url;
public CategoryParcel(Parcel in){
id = in.readLong();
category_resource = in.readInt();
categories = in.readString();
note = in.readString();
price = in.readInt();
quantity = in.readInt();
icon = in.readInt();
url = in.readString();
}
public CategoryParcel(){}
public CategoryParcel(Long id, String categories, String note, int price, int quantity, int icon){
this.id = id;
this.categories = categories;
this.note = note;
this.price = price;
this.quantity = quantity;
this.icon = icon;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public int getCategory_resource() {
return category_resource;
}
public void setCategory_resource(int category_resource) {
this.category_resource = category_resource;
}
public String getCategories() {
return categories;
}
public void setCategories(String categories) {
this.categories = categories;
}
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
public Integer getPrice() {
return price;
}
public void setPrice(Integer price) {
this.price = price;
}
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
public int getIcon() {
return icon;
}
public void setIcon(int icon) {
this.icon = icon;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeLong(id);
parcel.writeInt(category_resource);
parcel.writeString(categories);
parcel.writeString(note);
parcel.writeInt(price);
parcel.writeInt(quantity);
parcel.writeInt(icon);
}
public static final Parcelable.Creator<CategoryParcel> CREATOR = new Parcelable.Creator<CategoryParcel>()
{
public CategoryParcel createFromParcel(Parcel in)
{
return new CategoryParcel(in);
}
public CategoryParcel[] newArray(int size)
{
return new CategoryParcel[size];
}
};
}
错误指向此行:
public static final Parcelable.Creator CREATOR = new Parcelable.Creator()
如果您建议我可以分享更多详细信息。 我不知道我在这里做错了什么。
感谢阅读。 沙善
答案 0 :(得分:2)
我解决了这个问题,这与
有关编译'com.android.support:multidex:1.0.1'
最近Google发布了这个api以支持更低版本的android。
要检查的三件事:
{compile'com.android.support:multidex:1.0.1'}
defaultConfig {multiDexEnabled true}
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.multidex.myapplication"> <application ... android:name="android.support.multidex.MultiDexApplication"> ... </application> </manifest>
在我的情况下,我忘了添加第3点。
现在它工作正常,适用于所有预期的设备。
谢谢, Shashank Pratap