Android 运行时错误:找不到指向Parcelable的NoClassDefFoundError
请帮我解决这个问题,我被困在这里,我的应用程序在更高版本的设备上工作,MOGO G3和Moto XPlay,但当我在更低版本(16)的设备上测试时,它会给我错误,即NoClassDefFoundError 这是我的sdk配置: 明斯克版本16 targetSdkVersion 22 这是android在运行时无法找到的类:Android 运行时错误:找不到指向Parcelable的NoClassDefFoundError,android,projects-and-solutions,Android,Projects And Solutions,请帮我解决这个问题,我被困在这里,我的应用程序在更高版本的设备上工作,MOGO G3和Moto XPlay,但当我在更低版本(16)的设备上测试时,它会给我错误,即NoClassDefFoundError 这是我的sdk配置: 明斯克版本16 targetSdkVersion 22 这是android在运行时无法找到的类: public class CategoryParcel implements Parcelable{ private Long id; private int icon;
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类CategoryParcel实现可包裹{
私人长id;
私有int图标;
私有int类别资源;
私有字符串类别;
私人弦乐;
私人整数价格;
私有整数数量;
私有字符串url;
公共类别地块(地块位于){
id=in.readLong();
category_resource=in.readInt();
categories=in.readString();
note=in.readString();
price=in.readInt();
数量=in.readInt();
icon=in.readInt();
url=in.readString();
}
公共类别parcel(){}
公共类别PARCEL(长id、字符串类别、字符串注释、整数价格、整数数量、整数图标){
this.id=id;
这个。类别=类别;
this.note=注释;
这个价格=价格;
这个。数量=数量;
this.icon=图标;
}
公共长getId(){
返回id;
}
公共无效集合id(长id){
this.id=id;
}
public int getCategory_资源(){
返回类别资源;
}
public void setCategory_资源(int category_资源){
this.category\u resource=category\u resource;
}
公共字符串getCategories(){
退货类别;
}
公共void集合类别(字符串类别){
这个。类别=类别;
}
公共字符串getNote(){
退货单;
}
公共无效设置注释(字符串注释){
this.note=注释;
}
公共整数getPrice(){
退货价格;
}
公共定价(整数价格){
这个价格=价格;
}
公共整数getQuantity(){
退货数量;
}
公共无效设置数量(整数数量){
这个。数量=数量;
}
public int getIcon(){
返回图标;
}
公共无效设置图标(整数图标){
this.icon=图标;
}
@凌驾
公共int描述内容(){
返回0;
}
@凌驾
公共无效书面包裹(包裹,内部i){
包裹写长(id);
包裹写入(类别资源);
包裹。书面记录(类别);
包裹。书面记录(注);
包裹书面(价格);
包裹书写(数量);
包裹写入(图标);
}
public static final Parcelable.Creator=新建Parcelable.Creator()
{
公共类别Parcel createFromParcel(中的地块)
{
返回新的CategoryParcel(in);
}
public CategoryParcel[]新数组(整数大小)
{
返回新的CategoryParcel[大小];
}
};
}
错误指向此行:
public static final Parcelable.Creator=新建Parcelable.Creator()
如果你建议我可以分享更多细节。
我不知道我在这里做错了什么
谢谢你的阅读。
Shashank我解决了这个问题,这与 编译'com.android.support:multidex:1.0.1' 最近谷歌发布了这个api来支持android的低版本 要检查三件事:
...
在我的情况下,我忘记添加第3点
现在它工作良好,可以在所有预期的设备上工作
谢谢,
Shashank Pratap任何人,只要一个线索就足够了!我在一些设备上遇到了类似的问题,我的解决方案是清除项目并重建它。
<?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>