为什么我得到这个错误 "An error occured while executing doInBackground()" 。我哪里错了?
Why i get this Error "An error occured while executing doInBackground()" .where i am wrong?
为什么我会收到此错误
An error occured while executing doInBackground()
我哪里错了? LogCat如下图
这是我的 LoginActivity.java
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();
}
}
我没有在 doInBackGround 函数中做任何 UI 工作,但我仍然收到此错误。
LogCat:
09-26 02:20:32.209 27677-27897/com.gis.reliance.customercomplaintreports E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.gis.reliance.customercomplaintreports, PID: 27677
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.VerifyError: org/ksoap2/SoapEnvelope
at com.gis.reliance.customercomplaintreports.activity.LoginActivity.isAuthenticate(LoginActivity.java:141)
at com.gis.reliance.customercomplaintreports.activity.LoginActivity$AsyncCallWS.doInBackground(LoginActivity.java:160)
at com.gis.reliance.customercomplaintreports.activity.LoginActivity$AsyncCallWS.doInBackground(LoginActivity.java:157)
at android.os.AsyncTask.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
应用程序 运行-time JVM 和依赖库 JVM 版本应该没有区别。
为什么我会收到此错误
An error occured while executing doInBackground()
我哪里错了? LogCat如下图
这是我的 LoginActivity.java
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();
}
}
我没有在 doInBackGround 函数中做任何 UI 工作,但我仍然收到此错误。
LogCat:
09-26 02:20:32.209 27677-27897/com.gis.reliance.customercomplaintreports E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.gis.reliance.customercomplaintreports, PID: 27677
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.VerifyError: org/ksoap2/SoapEnvelope
at com.gis.reliance.customercomplaintreports.activity.LoginActivity.isAuthenticate(LoginActivity.java:141)
at com.gis.reliance.customercomplaintreports.activity.LoginActivity$AsyncCallWS.doInBackground(LoginActivity.java:160)
at com.gis.reliance.customercomplaintreports.activity.LoginActivity$AsyncCallWS.doInBackground(LoginActivity.java:157)
at android.os.AsyncTask.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
应用程序 运行-time JVM 和依赖库 JVM 版本应该没有区别。