I am trying to copy a database out of assets but in my createDatabase() method I am getting a null pointer exception. This occurs on the call to getReadableDatabase.
public static synchronized MetroLinkDatabaseHelper getInstance(Context context) {
// Using a singleton to minmize the chance of opening multiple
// decreasing any chance of memory leak
if(myInstance == null) {
myInstance = new MetroLinkDatabaseHelper(context);
}
return myInstance;
}
private MetroLinkDatabaseHelper(Context context) {
super(context, DB_NAME, null, 1);
this.mycontext = context;
boolean dbexist = checkdatabase();
if (dbexist) {
} else {
System.out.println("Database doesn't exist");
try {
createdatabase();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
// Create (copy the original in assets) if not exist using copydatabase
public void createdatabase() throws IOException {
boolean dbexist = checkdatabase();
if (dbexist) {
} else {
// SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
this.getReadableDatabase();
try {
copydatabase();
} catch (IOException e) {
throw new Error("Error copying database");
}
}
}
Here is the error log:
08-29 14:13:05.147 2222-2222/com.bkane56.practice.practiceapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.bkane56.practice.practiceapp, PID: 2222
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.bkane56.practice.practiceapp/com.bkane56.practice.practiceapp.ListStopsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int, android.database.sqlite.SQLiteDatabase$CursorFactory, android.database.DatabaseErrorHandler)' on a null object reference
at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
at com.bkane56.practice.practiceapp.MetroLinkDatabaseHelper.createdatabase(MetroLinkDatabaseHelper.java:66)
at com.bkane56.practice.practiceapp.MetroLinkDatabaseHelper.<init>(MetroLinkDatabaseHelper.java:52)
at com.bkane56.practice.practiceapp.MetroLinkDatabaseHelper.getInstance(MetroLinkDatabaseHelper.java:38)
at com.bkane56.practice.practiceapp.ListStopsActivity.<init>(ListStopsActivity.java:28)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1606)
at android.app.Instrumentation.newActivity(Instrumentation.java:1089)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2240)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5356)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Line 66 =
this.getReadableDatabase();
Any ideas? I did ask this question before in a much longer form but got no help.
Thanks
Your problem is here:
com.bkane56.practice.practiceapp.ListStopsActivity.<init>(ListStopsActivity.java:28)
You are attempting to do something with the Activity instance before the super.onCreate() call in the onCreate() method of that Activity. Generally, that does not work, with exceptions like this one.
Instead of calling getInstance() on MetroLinkDatabaseHelper from an initializer, move that call to after super.onCreate() in your onCreate() method.
Related
I want to predict hand written words using pre-trained model which is trained using CNN and RNN Combination. offline handwritten words recognizer without using server.
public void pickImage(View view) {
bitmap = BitmapFactory.decodeResource(getApplicationContext().getResources(),R.drawable.img1);
img.setImageBitmap(bitmap);
Toast.makeText(getApplicationContext(),"Width:- "+bitmap.getWidth()+" Height "+bitmap.getHeight(),Toast.LENGTH_SHORT).show();
convertBitmapToByte();
}
private void convertBitmapToByte()
{
if (mdata == null)
{
Toast.makeText(getApplicationContext(),"Return",Toast.LENGTH_SHORT).show();
return;
}
mdata.rewind();
bitmap.getPixels(getPixels,0,bitmap.getWidth(),0,0,bitmap.getWidth(),bitmap.getHeight());
int pixel =0;
for(int i=0;i<748;++i)
{
for(int j=0;j<294;++j)
{
final int val = getPixels[pixel++];
mdata.putFloat(convertToGreyScale(val));
}
}
}
private float convertToGreyScale(int colour)
{
return (((colour >> 16) & 0xFF)+((colour >>8) & 0xFF)+((colour & 0xFF)))/3.0f/255.0f;
}
public void predAndSet(View view) {
tv.setText("Temp");
if(mdata == null)
{
Toast.makeText(getApplicationContext(),"Return",Toast.LENGTH_SHORT).show();
return;
}
interpreter.run(mdata,mResult);
tv.setText(Arrays.toString(mResult[0]));
}
}
Stacktrace
Process: com.soham.s.charrecongizer, PID: 29211
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:6669)
at android.view.View.performClickInternal(View.java:6638)
at android.view.View.access$3100(View.java:789)
at android.view.View$PerformClick.run(View.java:26145)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
at android.view.View.performClick(View.java:6669)
at android.view.View.performClickInternal(View.java:6638)
at android.view.View.access$3100(View.java:789)
at android.view.View$PerformClick.run(View.java:26145)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.tensorflow.lite.Interpreter.run(java.lang.Object, java.lang.Object)' on a null object reference
at com.soham.s.charrecongizer.MainActivity.predAndSet(MainActivity.java:103)
I want to see the text in the image to be predicted and to be shown in a textbox
I have following class
public class Settings extends RealmObject {
private String something;
}
I want to add the following field
public class AndroidBuild extends RealmObject {
int one;
int two;
}
so it looks like
public class Settings extends RealmObject {
private String something;
private AndroidBuild androidBuild;
}
So, my migration looks like
if (oldVersion == 1) {
RealmObjectSchema settingsSchema = schema.get("Settings");
RealmObjectSchema androidBuildSchema = schema.get("AndroidBuild");
if (settingsSchema != null) {
settingsSchema.addRealmObjectField("androidBuild", androidBuildSchema);
oldVersion++;
}
}
and it crashes
07-11 15:05:06.384 9046-9046/com.cassby.terminal.cassby E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cassby.terminal.cassby, PID: 9046
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cassby.terminal.cassby/com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.realm.RealmObjectSchema.getClassName()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String io.realm.RealmObjectSchema.getClassName()' on a null object reference
at io.realm.MutableRealmObjectSchema.addRealmObjectField(MutableRealmObjectSchema.java:126)
at com.cassby.terminal.cassby.Services.Database.RealmMigrations.migrate(RealmMigrations.java:36)
at io.realm.BaseRealm$6.onMigrationNeeded(BaseRealm.java:714)
at io.realm.internal.OsSharedRealm.runMigrationCallback(OsSharedRealm.java:520)
at io.realm.internal.OsSharedRealm.nativeGetSharedRealm(Native Method)
at io.realm.internal.OsSharedRealm.<init>(OsSharedRealm.java:184)
at io.realm.internal.OsSharedRealm.getInstance(OsSharedRealm.java:254)
at io.realm.BaseRealm.<init>(BaseRealm.java:124)
at io.realm.BaseRealm.<init>(BaseRealm.java:93)
at io.realm.Realm.<init>(Realm.java:153)
at io.realm.Realm.createInstance(Realm.java:424)
at io.realm.RealmCache.doCreateRealmOrGetFromCache(RealmCache.java:342)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:282)
at io.realm.Realm.getDefaultInstance(Realm.java:332)
at com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity.resolveStartingActivity(LaunchActivity.java:35)
at com.cassby.terminal.cassby.UserStories.Launch.LaunchActivity.onCreate(LaunchActivity.java:29)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
What am I doing wrong ?
You need to add Table first, so
Realm.setDefaultConfiguration(new RealmConfiguration.Builder()
.name(DB_NAME)
.schemaVersion(SCHEMA_VERSION)
.migration((realm, oldVersion, newVersion) -> {
RealmSchema schema = realm.getSchema();
if (oldVersion == OLD_VERSION) {
schema.create("AndroidBuild")
.addField("one", int.class)
.addField("two", int.class);
schema.get("Settings")
.addRealmObjectField("androidBuild", schema.get("AndroidBuild"))
oldVersion++;
}
})
);
I'm working with OrmLite but I get an exception when I'm trying to use it into a IntentService:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: fr.solutis.solutis, PID: 29456
java.lang.RuntimeException: Unable to instantiate service fr.solutis.solutis.notifications.NotificationDemandeService:
java.lang.NullPointerException: Attempt to invoke virtual method
'android.content.res.Resources android.content.Context.getResources()'
on a null object reference
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3148)
at android.app.ActivityThread.access$1900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1513)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources
android.content.Context.getResources()' on a null object reference
at android.content.ContextWrapper.getResources(ContextWrapper.java:86)
at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.openFileId(OrmLiteSqliteOpenHelper.java:310)
at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.(OrmLiteSqliteOpenHelper.java:76)
at fr.solutis.solutis.helpers.DatabaseHelper.(DatabaseHelper.java:56)
at fr.solutis.solutis.notifications.NotificationDemandeService.(NotificationDemandeService.java:25)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1690)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3145)
at android.app.ActivityThread.access$1900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1513)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5910)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
code:
public class NotificationDemandeService extends IntentService {
DatabaseHelper db = new DatabaseHelper(NotificationDemandeService.this);
Boolean isInternetPresent = false;
Boolean isUrlAvailable = false;
ConnectionDetector cd;
String message = "";
public NotificationDemandeService() {
super("EnvoieService");
}
#Override
protected void onHandleIntent(Intent intent) {
try {
List<Demandes> demandes = db.getAllDemandesRenvoie();
...
} catch (SQLException e) {
e.printStackTrace();
}
....
}
}
just by calling:
DatabaseHelper db = new DatabaseHelper(this);
after:
#Override
protected void onHandleIntent(Intent intent)
Gonna work, I don't understand the issue, but it works !
I am getting a NullPointerException from calling
ParseTwitterUtils.initialize(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
Here is the stack trace
java.lang.RuntimeException: Unable to create application com.myapp.app.android.Application: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5015)
at android.app.ActivityThread.access$1600(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
at com.parse.Parse.getParseDir(Parse.java:313)
at com.parse.ParseCorePlugins.getCurrentUserController(ParseCorePlugins.java:124)
at com.parse.ParseUser.getCurrentUserController(ParseUser.java:56)
at com.parse.ParseUser.getCurrentUser(ParseUser.java:892)
at com.parse.ParseUser.getCurrentUser(ParseUser.java:879)
at com.parse.ParseUser.registerAuthenticationProvider(ParseUser.java:1125)
at com.parse.ParseTwitterUtils.getAuthenticationProvider(ParseTwitterUtils.java:20)
at com.parse.ParseTwitterUtils.initialize(ParseTwitterUtils.java:50)
at com.myapp.app.android.Application.onCreate(Application.java:42)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5012)
at android.app.ActivityThread.access$1600(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
My app used to work before I added the line ParseTwitterUtils.initialize(...). Here is the onCreate method of my Application class
public void onCreate(){
super.onCreate();
registerDatabaseTables();
ParseTwitterUtils.initialize(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
Parse.enableLocalDatastore(this);
Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
}
Unfortunately the instructions on parse.com do not say this, but you have to initialize Parse before you initialize Twitter. This is not obvious since you are required to do so much before you initialize parse. So anyway change your code to this:
public void onCreate(){
super.onCreate();
registerDatabaseTables();
Parse.enableLocalDatastore(this);
Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
ParseTwitterUtils.initialize(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET);
}
I am getting Null Pointer Exception on line 219: amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);. It was not happening before, today i saw it first time, i am using Android 5.0. Code mutes notification sound when activity starts and unmutes when it is destroyed.
Code:
private AudioManager amanager;
#Override
protected void onCreate(Bundle savedInstanceState) {
amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
}
#Override
protected void onResume() {
super.onResume();
if(amanager!=null) {
amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
}
}
#Override
protected void onPause() {
if(amanager!=null) {
amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false);
}
super.onPause();
}
Error:
java.lang.RuntimeException: Unable to resume activity {com.jemshit.itu/com.jemshit.nfcAttendance.ClassActivity}: java.lang.NullPointerException: Null pointer exception during instruction 'invoke-static {v0}, android.os.IBinder android.media.AudioService$VolumeStreamState$VolumeDeathHandler.access$5300(android.media.AudioService$VolumeStreamState$VolumeDeathHandler) // method#11492'
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3346)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2728)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.NullPointerException: Null pointer exception during instruction 'invoke-static {v0}, android.os.IBinder android.media.AudioService$VolumeStreamState$VolumeDeathHandler.access$5300(android.media.AudioService$VolumeStreamState$VolumeDeathHandler) // method#11492'
at android.os.Parcel.readException(Parcel.java:1546)
at android.os.Parcel.readException(Parcel.java:1493)
at android.media.IAudioService$Stub$Proxy.setStreamMute(IAudioService.java:992)
at android.media.AudioManager.setStreamMute(AudioManager.java:1466)
at com.jemshit.nfcAttendance.ClassActivity.onResume(ClassActivity.java:219)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1255)
at android.app.Activity.performResume(Activity.java:6338)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3335)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2728)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
It's an Android bug it's not your code. Put a try/catch block in your code to avoid the crash.