Android 2.3.4 (エミュレーター/電話) で完全に動作するアプリがあります。しかし、Android 4.0.3 (エミュレーター/電話) にインストールしようとしましたが、実行しても機能しません。このメッセージが表示されます
"Unfortunately AppName has stopped"
アプリがこれらのクラスを実行しているときにエラーが表示される場合:
public class EmpleadosAct extends Activity {
private ArrayList<String> datos;
private ListView list;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActualizarVehiculos();
}
public void ActualizarVehiculos() {
try {
NotesCenter messageCenter = new NotesCenterImpl();
List<Vehiculo> vehiculo = messageCenter.getVehiculo();
for (Vehiculo v : vehiculo) {
AndroidOpenDbHelper androidOpenDbHelperObj = new AndroidOpenDbHelper(
this);
SQLiteDatabase sqliteDatabase = androidOpenDbHelperObj
.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(AndroidOpenDbHelper.matricula, v.matricula);
long affectedColumnId = sqliteDatabase.insert("Vehiculos",
null, contentValues);
sqliteDatabase.close();
}
} catch (Exception ex) {
Log.v("blah", ex.getMessage());
}
}
}
2 番目のクラス:
public class SeleccionarEmpleado extends Activity implements OnClickListener,
OnItemClickListener {
private ListView listaEmpleados;
private EditText ECont;
String text;
Bundle dataBundle;
public EmpleadosAct actemple;
protected AppApplication app;
private ListAdapter uGraduateListAdapter;
private ArrayList<UndergraduateDetailsPojo> pojoArrayList;
private String contraseña;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seleccionarempleado);
***Intent actServicios = new Intent(this, EmpleadosAct.class);
startActivity(actServicios);***
listaEmpleados = (ListView) findViewById(R.id.ListaEmpleados);
listaEmpleados.setOnItemClickListener(this);
pojoArrayList = new ArrayList<UndergraduateDetailsPojo>();
uGraduateListAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, populateList());
listaEmpleados.setAdapter(uGraduateListAdapter);
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.actualizar:
//Intent actualizarEmpleados = new Intent(this,EmpleadosAct.class);
//startActivity(actualizarEmpleados);
//return true;
case R.id.opciones:
Toast.makeText(SeleccionarEmpleado.this, "Save is Selected",
Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void onClick(View v) {
Intent addNewUndergraduateIntent = new Intent(this,
InsertarPedido.class);
startActivity(addNewUndergraduateIntent);
}
public List<String> populateList() {
List<String> uGraduateNamesList = new ArrayList<String>();
AndroidOpenDbHelper openHelperClass = new AndroidOpenDbHelper(this);
SQLiteDatabase sqliteDatabase = openHelperClass.getReadableDatabase();
Cursor cursor = sqliteDatabase.query("Empleados", null, null, null,
null, null, null);
startManagingCursor(cursor);
while (cursor.moveToNext()) {
String idempleado = cursor.getString(cursor
.getColumnIndex(AndroidOpenDbHelper.idempleado));
String nombre = cursor.getString(cursor
.getColumnIndex(AndroidOpenDbHelper.nombre));
String primerapellido = cursor.getString(cursor
.getColumnIndex(AndroidOpenDbHelper.primerapellido));
String segundoapellido = cursor.getString(cursor
.getColumnIndex(AndroidOpenDbHelper.segundoapellido));
String contra = cursor.getString(cursor
.getColumnIndex(AndroidOpenDbHelper.contra));
UndergraduateDetailsPojo ugPojoClass = new UndergraduateDetailsPojo();
ugPojoClass.setIdEmpleado(idempleado);
ugPojoClass.setNombreEmpleado(nombre);
ugPojoClass.setPrimerApellido(primerapellido);
ugPojoClass.setSegundoApellido(segundoapellido);
ugPojoClass.setContra(contra);
pojoArrayList.add(ugPojoClass);
uGraduateNamesList.add(nombre + " " + primerapellido + " "
+ segundoapellido);
}
sqliteDatabase.close();
return uGraduateNamesList;
}
@Override
protected void onResume() {
super.onResume();
uGraduateListAdapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, populateList());
listaEmpleados.setAdapter(uGraduateListAdapter);
}
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
UndergraduateDetailsPojo clickedObject = pojoArrayList.get(arg2);
String Empleado = clickedObject.getNombreEmpleado() + " "
+ clickedObject.getPrimerApellido() + " "
+ clickedObject.getSegundoApellido();
Empleado empleadoseleccionado = new Empleado();
empleadoseleccionado.id = clickedObject.getIdEmpleado();
empleadoseleccionado.nombre = Empleado;
app = (AppApplication)getApplicationContext();
app.setempleadoActual(empleadoseleccionado);
app.setempleadoId(empleadoseleccionado);
}
}
最初は2番目のクラスを実行しており、2番目のクラスには最初のクラスを開くIntentがあります。最初のクラスは、リモート サーバーから Android SQLite データベースにデータを追加します。そして、2 番目のクラスは、Android SQLite データベースからのこの結果を示しています。
これはログです:
06-04 21:08:13.034: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
06-04 21:08:13.054: E/AndroidRuntime(517): FATAL EXCEPTION: main
06-04 21:08:13.054: E/AndroidRuntime(517): java.lang.RuntimeException: Unable to start activity ComponentInfo{dokesim.net/myapp.net.EmpleadosAct}: java.lang.NullPointerException: println needs a message
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:137)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-04 21:08:13.054: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
06-04 21:08:13.054: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:511)
06-04 21:08:13.054: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-04 21:08:13.054: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-04 21:08:13.054: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
06-04 21:08:13.054: E/AndroidRuntime(517): Caused by: java.lang.NullPointerException: println needs a message
06-04 21:08:13.054: E/AndroidRuntime(517): at android.util.Log.println_native(Native Method)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.util.Log.v(Log.java:117)
06-04 21:08:13.054: E/AndroidRuntime(517): at myapp.net.EmpleadosAct.ActualizarVehiculos(EmpleadosAct.java:133)
06-04 21:08:13.054: E/AndroidRuntime(517): at myapp.net.EmpleadosAct.onCreate(EmpleadosAct.java:24)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.Activity.performCreate(Activity.java:4465)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-04 21:08:13.054: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-04 21:08:13.054: E/AndroidRuntime(517): ... 11 more
2 番目のログ:
06-04 21:40:03.225: V/blah(720): Error happened:
06-04 21:40:03.225: V/blah(720): android.os.NetworkOnMainThreadException
06-04 21:40:03.225: V/blah(720): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
06-04 21:40:03.225: V/blah(720): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
06-04 21:40:03.225: V/blah(720): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
06-04 21:40:03.225: V/blah(720): at libcore.io.IoBridge.connect(IoBridge.java:112)
06-04 21:40:03.225: V/blah(720): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
06-04 21:40:03.225: V/blah(720): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
06-04 21:40:03.225: V/blah(720): at java.net.Socket.connect(Socket.java:842)
06-04 21:40:03.225: V/blah(720): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119 )
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-04 21:40:03.225: V/blah(720): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
06-04 21:40:03.225: V/blah(720): at myapp.net.HttpNote.doGet(HttpNote.java:32)
06-04 21:40:03.225: V/blah(720): at myapp.net.NotesCenterImpl.getVehiculo(NotesCenterImpl.java:23)
06-04 21:40:03.225: V/blah(720): at myapp.net.EmpleadosAct.ActualizarVehiculo(EmpleadosAct.java:91)
06-04 21:40:03.225: V/blah(720): at myapp.net.EmpleadosAct.onCreate(EmpleadosAct.java:24)
06-04 21:40:03.225: V/blah(720): at android.app.Activity.performCreate(Activity.java:4465)
06-04 21:40:03.225: V/blah(720): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-04 21:40:03.225: V/blah(720): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-04 21:40:03.225: V/blah(720): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-04 21:40:03.225: V/blah(720): at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-04 21:40:03.225: V/blah(720): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-04 21:40:03.225: V/blah(720): at android.os.Handler.dispatchMessage(Handler.java:99)
06-04 21:40:03.225: V/blah(720): at android.os.Looper.loop(Looper.java:137)
06-04 21:40:03.225: V/blah(720): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-04 21:40:03.225: V/blah(720): at java.lang.reflect.Method.invokeNative(Native Method)
06-04 21:40:03.225: V/blah(720): at java.lang.reflect.Method.invoke(Method.java:511)
06-04 21:40:03.225: V/blah(720): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-04 21:40:03.225: V/blah(720): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-04 21:40:03.225: V/blah(720): at dalvik.system.NativeStart.main(Native Method)
では、2.3.4 android ではすべて正常に動作し、4.0.3 では動作しない原因は何ですか? 4.0.3 バージョンをサポートしていない私のコードに問題がありますか?
回答や提案をありがとう。