• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps My app crashes and restart when trying to use constructor?

Kalleyo

Lurker
So im trying to make a login database for my app, however when i get to the registrering new elements to the database the app crashes and restarts for some reason. I dont know why but ive found out and marked where the roblem is, hope somone can enlighten me as to what im doing wrong.

Here is the place that im trying to add an object to the database based on some user inputs, this is also were the problem is as it does not crash if i comment it out:
https://i.imgsafe.org/7c8bd1c6db.png

Here is the class of a database item which constructor im trying to make:
https://i.imgsafe.org/7c8bc75e47.png

Any tips would be appreciated, cheers! :)
 
Last edited:
Please post the stack trace from your Logcat output.
Im not entirely sure what your asking for, is this it?

03-14 12:40:26.133 17485-17485/? E/Zygote: MountEmulatedStorage()
03-14 12:40:26.133 17485-17485/? E/Zygote: v2
03-14 12:40:26.133 17485-17485/? I/libpersona: KNOX_SDCARD checking this for 10124
03-14 12:40:26.133 17485-17485/? I/libpersona: KNOX_SDCARD not a persona
03-14 12:40:26.133 17485-17485/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-J320FN_5.1.1_0052
03-14 12:40:26.133 17485-17485/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
03-14 12:40:26.133 17485-17485/? I/art: Late-enabling -Xcheck:jni
03-14 12:40:26.133 17485-17485/? E/art: setrlimit(RLIMIT_CORE) failed for pid 17485: Operation not permitted
03-14 12:40:26.163 17485-17492/? I/art: Debugger is no longer active
03-14 12:40:26.193 17485-17485/? W/ResourcesManager: getTopLevelResources: /data/app/com.example.lars_peter.babydonthurtme-1/base.apk / 1.0 running in com.example.lars_peter.babydonthurtme rsrc of package com.example.lars_peter.babydonthurtme
03-14 12:40:26.193 17485-17485/? I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
03-14 12:40:26.203 17485-17485/? D/ResourcesManager: For user 0 new overlays fetched Null
03-14 12:40:26.203 17485-17485/? W/ActivityThread: Application com.example.lars_peter.babydonthurtme is waiting for the debugger on port 8100...
03-14 12:40:26.203 17485-17485/? I/System.out: Sending WAIT chunk
03-14 12:40:27.714 17485-17492/com.example.lars_peter.babydonthurtme I/art: Debugger is active
03-14 12:40:27.804 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: Debugger has connected
03-14 12:40:27.814 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:28.014 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:28.215 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:28.415 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:28.615 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:28.815 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:29.015 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:29.216 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:29.416 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: waiting for debugger to settle...
03-14 12:40:29.616 17485-17485/com.example.lars_peter.babydonthurtme I/System.out: debugger has settled (1418)
03-14 12:40:29.616 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: Inside getClassLibPath caller
03-14 12:40:29.846 17485-17485/com.example.lars_peter.babydonthurtme D/InjectionManager: InjectionManager
03-14 12:40:29.846 17485-17485/com.example.lars_peter.babydonthurtme D/InjectionManager: fillFeatureStoreMap com.example.lars_peter.babydonthurtme
03-14 12:40:29.846 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: Constructor com.example.lars_peter.babydonthurtme, Feature store :{}
03-14 12:40:29.846 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: featureStore :{}
03-14 12:40:29.976 17485-17485/com.example.lars_peter.babydonthurtme W/ResourcesManager: getTopLevelResources: /data/app/com.example.lars_peter.babydonthurtme-1/base.apk / 1.0 running in com.example.lars_peter.babydonthurtme rsrc of package com.example.lars_peter.babydonthurtme
03-14 12:40:29.986 17485-17485/com.example.lars_peter.babydonthurtme W/ResourcesManager: getTopLevelResources: /data/app/com.example.lars_peter.babydonthurtme-1/base.apk / 1.0 running in com.example.lars_peter.babydonthurtme rsrc of package com.example.lars_peter.babydonthurtme
03-14 12:40:29.986 17485-17485/com.example.lars_peter.babydonthurtme W/ResourceType: Failure getting entry for 0x01080946 (t=7 e=2374) (error -75)
03-14 12:40:30.046 17485-17485/com.example.lars_peter.babydonthurtme W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-14 12:40:30.136 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* installDecor mIsFloating : false
03-14 12:40:30.136 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* installDecor flags : -2139029248
03-14 12:40:30.327 17485-17485/com.example.lars_peter.babydonthurtme D/Activity: performCreate Call Injection manager
03-14 12:40:30.337 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchOnViewCreated > Target : com.example.lars_peter.babydonthurtme.LoginActivity isFragment :false
03-14 12:40:30.367 17485-17564/com.example.lars_peter.babydonthurtme D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
03-14 12:40:30.387 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
03-14 12:40:30.387 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
03-14 12:40:30.427 17485-17564/com.example.lars_peter.babydonthurtme I/OpenGLRenderer: Initialized EGL, version 1.4
03-14 12:40:30.427 17485-17564/com.example.lars_peter.babydonthurtme D/OpenGLRenderer: Get maximum texture size. GL_MAX_TEXTURE_SIZE is 4096
03-14 12:40:30.427 17485-17564/com.example.lars_peter.babydonthurtme D/OpenGLRenderer: Enabling debug mode 0
03-14 12:40:30.507 17485-17485/com.example.lars_peter.babydonthurtme W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
03-14 12:40:30.517 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchCreateOptionsMenu :com.example.lars_peter.babydonthurtme.LoginActivity
03-14 12:40:30.517 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchPrepareOptionsMenu :com.example.lars_peter.babydonthurtme.LoginActivity
03-14 12:40:30.577 17485-17485/com.example.lars_peter.babydonthurtme I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@3f269158 time:45428116
03-14 12:40:38.685 17485-17485/com.example.lars_peter.babydonthurtme D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
03-14 12:40:38.805 17485-17485/com.example.lars_peter.babydonthurtme I/Timeline: Timeline: Activity_launch_request id:com.example.lars_peter.babydonthurtme time:45436349
03-14 12:40:38.935 17485-17485/com.example.lars_peter.babydonthurtme W/ResourcesManager: getTopLevelResources: /data/app/com.example.lars_peter.babydonthurtme-1/base.apk / 1.0 running in com.example.lars_peter.babydonthurtme rsrc of package com.example.lars_peter.babydonthurtme
03-14 12:40:38.935 17485-17485/com.example.lars_peter.babydonthurtme W/ResourceType: Failure getting entry for 0x01080946 (t=7 e=2374) (error -75)
03-14 12:40:38.955 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* installDecor mIsFloating : false
03-14 12:40:38.955 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* installDecor flags : -2139029248
03-14 12:40:38.995 17485-17485/com.example.lars_peter.babydonthurtme D/Activity: performCreate Call Injection manager
03-14 12:40:38.995 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchOnViewCreated > Target : com.example.lars_peter.babydonthurtme.RegisterActivity isFragment :false
03-14 12:40:39.025 17485-17564/com.example.lars_peter.babydonthurtme V/RenderScript: 0xb4821c00 Launching thread(s), CPUs 4
03-14 12:40:39.045 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
03-14 12:40:39.045 17485-17485/com.example.lars_peter.babydonthurtme D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
03-14 12:40:39.095 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchCreateOptionsMenu :com.example.lars_peter.babydonthurtme.RegisterActivity
03-14 12:40:39.095 17485-17485/com.example.lars_peter.babydonthurtme I/InjectionManager: dispatchPrepareOptionsMenu :com.example.lars_peter.babydonthurtme.RegisterActivity
03-14 12:40:39.215 17485-17564/com.example.lars_peter.babydonthurtme D/OpenGLRenderer: endAllStagingAnimators on 0xa30ea900 (RippleDrawable) with handle 0xa30fefe0
03-14 12:40:39.275 17485-17485/com.example.lars_peter.babydonthurtme I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1cd261fa time:45436817
03-14 12:40:39.476 17485-17485/com.example.lars_peter.babydonthurtme V/ActivityThread: updateVisibility : ActivityRecord{34db3d9b token=android.os.BinderProxy@3f269158 {com.example.lars_peter.babydonthurtme/com.example.lars_peter.babydonthurtme.LoginActivity}} show : false
03-14 12:40:40.817 17485-17485/com.example.lars_peter.babydonthurtme D/InputMethodManager: windowDismissed mLockisused = false
03-14 12:40:43.459 17485-17485/com.example.lars_peter.babydonthurtme D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
03-14 12:40:43.570 17485-17485/com.example.lars_peter.babydonthurtme E/SQLiteLog: (1) near "AUTOINCREMENTname": syntax error
03-14 12:40:43.570 17485-17485/com.example.lars_peter.babydonthurtme D/AndroidRuntime: Shutting down VM
03-14 12:40:43.570 17485-17485/com.example.lars_peter.babydonthurtme E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lars_peter.babydonthurtme, PID: 17485
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
at android.view.View.performClick(View.java:5246)
at android.widget.TextView.performClick(TextView.java:10620)
at android.view.View$PerformClick.run(View.java:21256)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
at android.view.View.performClick(View.java:5246)
at android.widget.TextView.performClick(TextView.java:10620)
at android.view.View$PerformClick.run(View.java:21256)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: android.database.sqlite.SQLiteException: near "AUTOINCREMENTname": syntax error (code 1): , while compiling: CREATE TABLE items(id INTEGER PRIMARY KEY AUTOINCREMENTname TEXT email TEXT password TEXT );
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(near "AUTOINCREMENTname": syntax error (code 1): , while compiling: CREATE TABLE items(id INTEGER PRIMARY KEY AUTOINCREMENTname TEXT email TEXT password TEXT );)
#################################################################
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1067)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:644)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1812)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1743)
at com.example.lars_peter.babydonthurtme.MýDBHandler.onCreate(MýDBHandler.java:44)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.lars_peter.babydonthurtme.MýDBHandler.AddItem(MýDBHandler.java:63)
at com.example.lars_peter.babydonthurtme.RegisterActivity.FinishButtonClicked(RegisterActivity.java:52)
... 14 more
 
This is your problem. You have a syntax error in your DB table creation statement:

Caused by: android.database.sqlite.SQLiteException: near "AUTOINCREMENTname": syntax error (code 1): , while compiling: CREATE TABLE items(id INTEGER PRIMARY KEY AUTOINCREMENTname TEXT email TEXT password TEXT );

Which is in

at com.example.lars_peter.babydonthurtme.MýDBHandler.onCreate(MýDBHandler.java:44)

You should become familiar with reading the stack trace, as it tells you what went wrong.
 
This is your problem. You have a syntax error in your DB table creation statement:



Which is in



You should become familiar with reading the stack trace, as it tells you what went wrong.
Yeah thats probably a good idea(im still new to Android studio) but ill look into it, thanks! :D
 
Back
Top Bottom