简体   繁体   English

在类com.potenza_pvt_ltd.AAPS.TruckDetailsActivity上找不到“车辆类型”的设置程序/字段

[英]No setter/field for Vehicle Type found on class com.potenza_pvt_ltd.AAPS.TruckDetailsActivity

I have seen others ask this question but it seems to me that I have done all the things that are required and I'm still not getting it to work. 我已经看到其他人提出了这个问题,但是在我看来,我已经完成了所有必需的工作,但是我仍然没有使它起作用。 I am getting the No setter/field for Vehicle Type found on class No setter/field for Time of Arrival found on class No setter/field for Driver Number found on class No setter/field for Vehicle Number found on class No setter/field for Time of Departure found on class No setter/field for Partial Amount Paid found on class 我在班级上没有找到车辆类型的设置器/字段在班级上没有找到到达时间的设置器/字段在班级没有找到驾驶员号的设置器/字段在班级没有设置器/字段的找到器/字段在班级上发现了出发时间在班级上未找到特定金额的付款人/字段

public class TruckDetailsActivity {
        //name and address string
    @JsonProperty("Transporter")
        private String Transporter;
    @JsonProperty("Driver Name")
    private String DriverName;

    public void setVehicleType(String vehicleType) {
        VehicleType = vehicleType;
    }

    @JsonProperty("Driver Number")
        private String DriverNumber;
    @JsonProperty("Vehicle Number")
        private String VehicleNumber;
    @JsonProperty("Date")
        private String Date;
    @JsonProperty("aps")
        private String aps;
    @JsonProperty("email")
    private String email;
    private String key;
    @JsonProperty("Time of Arrival")
    private String TimeofArrival;
    @JsonProperty("Cost")
    private String Cost;
    @JsonProperty("Time of Departure")
    private String TimeofDeparture;
    @JsonProperty("Partial Amount Paid")
    private String PartialAmountPaid;
    @JsonProperty("Vehicle Type")
    private String VehicleType;

    @JsonProperty("Cash Handover")
    private String CashHandover;

    @JsonProperty("Operator")
    private String Operator;
    public TruckDetailsActivity() {

            /*Blank default constructor essential for Firebase*/
        }
    public TruckDetailsActivity(String a){

    }
    public TruckDetailsActivity(String k, String s, String index, String index1, String index2, String index3) {
        this.key=k;
        email=s;
        Transporter =index;
        DriverNumber =index1;
        Date =index2;
        aps =index3;
    }

    @JsonProperty("Key")
    public String getKey(){
        return this.key;
    }
    public void setKey(String key){
        this.key=key;
    }
    //Getters and setters
    public String getTransporter() {
            return this.Transporter;
        }
    public void setTransporter(String contractorname) {
            this.Transporter = contractorname;
        }

    public String getDriverName() {
            return this.DriverName;
        }

    public void setDriverName(String driverName) {
        this.DriverName = driverName;
    }
    public String getDriverNumber() {
            return this.DriverNumber;
        }
    public String getVehicleNumber() {
            return this.VehicleNumber;
        }

    public String getDate() {
            return this.Date;
        }


    public void setDate(String date) {
            this.Date = date;
        }


    public String getAps() {
        return this.aps;
    }

    public void setAps(String aps) {
        this.aps = aps;
    }

    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email){this.email=email;}

    public String getTimeofArrival() {
        return this.TimeofArrival;
    }


    public String getCost() {
        return this.Cost;
    }

    public void setCost(String T) {
        this.Cost = T;
    }

    public String getTimeofDeparture() {
        return TimeofDeparture;
    }


    public String getPartialAmountPaid() {
        return PartialAmountPaid;
    }


    public String getVehicleType() {
        return VehicleType;
    }


    public String getCashHandover() {
        return CashHandover;
    }

    public void setCashHandover(String cashHandover) {
        CashHandover = cashHandover;
    }


    public String getOperator() {
        return Operator;
    }

    public void setOperator(String operator){this.Operator=operator;}

This is my Java file from where i call the above class.

    Query queryRef = reference.child("users").child("data").orderByChild(sort);
        queryRef.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for(DataSnapshot ds:dataSnapshot.getChildren()){
                    TruckDetailsActivity post = ds.getValue(TruckDetailsActivity.class);
                    post.setKey(ds.getKey());
                    Log.d("post", post.getKey());
                    TruckDetailsActivity obj = new TruckDetailsActivity(post.getKey(), post.getEmail(), post.getTransporter(), post.getDriverNumber(), post.getDate(), post.getAps());
                    list.add(index, obj);
                    Log.d("list", String.valueOf(list.get(index)));
                    index++;
                }
                mAdapter = new MyRecyclerViewAdapter(list);
                mAdapter.notifyDataSetChanged();
                Log.d("count of list", String.valueOf(mAdapter.getItemCount()));
                mRecyclerView.setAdapter(mAdapter);
                pb.setVisibility(View.GONE);
                linearLayout.setVisibility(View.VISIBLE);

            }

            @Override
            public void onCancelled(DatabaseError firebaseError) {

            }
        });

Gradle Build Gradle构建

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.potenza_pvt_ltd.AAPS"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:design:22.2.1'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'
    //compile 'com.firebase:firebase-client-android:2.3.1'
    compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
    compile 'com.google.firebase:firebase-database:9.0.0'
    compile 'com.google.firebase:firebase-auth:9.0.0'
    compile 'com.google.firebase:firebase-storage:9.0.0'
    compile files('libs/poi-3.14-20160307.jar')
    compile files('libs/joda-time-2.9.4.jar')
    compile files('libs/jackson-annotations-2.2.3.jar')
}

apply plugin: 'com.google.gms.google-services'

It looks like you created a Firebase database using a previous version of your app that was built using the legacy (2.xx) SDK. 您似乎使用的是使用旧版(2.xx)SDK构建的应用程序的早期版本创建了Firebase数据库。 The legacy SDK uses Jackson for converting to/from JSON. 旧版SDK使用Jackson来进行JSON转换。 You used the Jackson annotation @JsonProperty and specified names containing spaces. 您使用了Jackson批注@JsonProperty并指定了包含空格的名称。

You have now upgraded your app to use the new SDK, which does not use Jackson and instead expects JavaBean getter/setter naming conventions for conversion of POJO classes to/from JSON. 现在,您已经升级了应用程序以使用新的SDK,该SDK不使用Jackson,而是期望JavaBean getter / setter命名约定将POJO类转换为JSON。 This creates a problem with your database fields whose names have spaces in them, such as "Driver Number". 这会给您的数据库字段(其中名称中包含空格)(例如“驱动程序编号”)造成问题。

The only solution I know of is to go to the Firebase console and export your database to a JSON file, edit it manually to replace the field names that contain spaces, then import back into Firebase. 我知道的唯一解决方案是转到Firebase控制台并将数据库导出到JSON文件,手动对其进行编辑以替换包含空格的字段名称,然后再导入回Firebase。 The export/import actions are available in the overflow menu icon (three vertical dots) at the upper right corner of the Firebase console database tab. Firebase控制台数据库选项卡右上角的溢出菜单图标(三个垂直点)中提供了导出/导入操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM