为什么我得到这个错误"执行doInBackground()"时发生错误我哪里错了?

时间:2016-09-25 20:59:35

标签: android android-ksoap2

为什么我收到此错误

  

执行doInBackground()

时发生错误

我哪里错了? LogCat如下所示

这是 LoginActivity.java

django.core.exceptions.FieldError: Auto-generated field 'parentmodel_ptr' in class 'ChildModel' for parent_link to base class 'ParentModel' clashes with declared field of the same name.

我没有在doInBackGround函数中执行任何UI工作,但我仍然遇到此错误。

logcat的:

public class LoginActivity extends AppCompatActivity {
    private static EditText username_edit_text;
    private static Button login_button;
    private static RadioGroup lang_group;
    RadioButton mar_radio_button;
    RadioButton eng_radio_button;
    TextView tv;
    String lang = "en";
    private Locale myLocale;
    Resources res;
    private final String NAMESPACE = "http://tempuri.org/";
    private final String URL = "http://My_server_ip/MobileLDAP/Service.asmx";
    private final String SOAP_ACTION = "http://tempuri.org/OMS_Authenticate_Crew";
    private final String METHOD_NAME = "OMS_Authenticate_Crew";
    private static String username;
    private static String resultm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        final ConnectionDetector cd = new ConnectionDetector();
        username_edit_text = (EditText) findViewById(R.id.ET_UserName);
        login_button = (Button) findViewById(R.id.Button_login);
        lang_group = (RadioGroup) findViewById(R.id.radioType);
        mar_radio_button = (RadioButton) findViewById(R.id.radioMar);
        eng_radio_button = (RadioButton) findViewById(R.id.radioEng);
        tv = (TextView) findViewById(R.id.tv);
        setTitle(getResources().getString(R.string.app_name));
        res = getResources();
        final Locale locale = res.getConfiguration().locale;
        lang_group.setOnCheckedChangeListener(
                new RadioGroup.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(RadioGroup group, int checkedId) {
                        if (locale.getLanguage().equals("mr")) {
                            mar_radio_button.setEnabled(false);
                            if (eng_radio_button.isChecked()) {
                                lang = "en";
                                setLocale(lang);
                            }
                        } else {
                            eng_radio_button.setEnabled(false);
                            if (mar_radio_button.isChecked()) {
                                lang = "mr";
                                setLocale(lang);
                            }
                        }
                    }
                });

        login_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                username = username_edit_text.getText().toString();
                AsyncCallWS task = new AsyncCallWS();
                task.execute();
            }
        });
    }

    protected void isAuthenticate(String Payroll_no) {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo Payroll_info = new PropertyInfo();
        Payroll_info.setName("Payroll_no");
        Payroll_info.setValue(Payroll_no);
        Payroll_info.setType(double.class);
        request.addProperty(Payroll_info);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            resultm = response.toString();
        } catch (Exception e) {
            resultm = e.toString();
        }
    }

    private class AsyncCallWS extends AsyncTask<String, Void, Void> {
        @Override
        protected Void doInBackground(String... params) {
            isAuthenticate(username);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            tv.setText(resultm);
        }

        @Override
        protected void onPreExecute() {
        }

        @Override
        protected void onProgressUpdate(Void... values) {
        }
    }

    public void setLocale(String lang) {
        myLocale = new Locale(lang);
        res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;
        res.updateConfiguration(conf, dm);
        sharedPreferences = getSharedPreferences("CommonPref", Activity.MODE_PRIVATE);
        Intent refresh = new Intent(getApplicationContext(), LoginActivity.class);
        startActivity(refresh);
        finish();
    }
}

1 个答案:

答案 0 :(得分:1)

应用程序运行时JVM和相关的lib JVM版本不应该有所不同。