shared preference & storage permission - permissions

I have some data saved to my Shared Preferences i am able to access it until i am not changing storage permission explicitly in application permission in marshmallow(Does not matter in first time this is allowed or not).
CASE 1: when i change storage permission to allow for any task at run time this is working fine,NO issue.
Case 2: again i try to read from shared preference but this time i have denied storage permission explicitly in application permission, its crashes with a null pointer exception,
kindly confirm storage permission is related to external storage or internal storage as well as shared preference.
log for error :
**02-03 12:59:52.235: E/AndroidRuntime(6970): at android.os.AsyncTask$3.done(AsyncTask.java:309)**
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-03 12:59:52.235: E/AndroidRuntime(6970): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.lang.Thread.run(Thread.java:818)
02-03 12:59:52.235: E/AndroidRuntime(6970): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'byte[] com.necdisplay.IntlWirelessDataApp.common.SpecialClassMappingForSharedPreference.getData()' on a null object reference
02-03 12:59:52.235: E/AndroidRuntime(6970): at com.necdisplay.IntlWirelessDataApp.common.Function.compareAndUpdateModelName(Function.java:3549)
02-03 12:59:52.235: E/AndroidRuntime(6970): at com.necdisplay.IntlWirelessDataApp.common.Function.readModelName(Function.java:3665)
02-03 12:59:52.235: E/AndroidRuntime(6970): at com.necdisplay.IntlWirelessDataApp.common.Function.readServiceData(Function.java:2539)
02-03 12:59:52.235: E/AndroidRuntime(6970): at com.necdisplay.IntlWirelessDataApp.common.ReadWriteTask.doInBackground(ReadWriteTask.java:229)
02-03 12:59:52.235: E/AndroidRuntime(6970): at android.os.AsyncTask$2.call(AsyncTask.java:295)
02-03 12:59:52.235: E/AndroidRuntime(6970): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-03 12:59:52.235: E/AndroidRuntime(6970): ... 4 more
02-03 12:59:52.431: I/com.necdisplay.IntlWirelessDataApp.common.Utility(6970): getFileList
02-03 12:59:52.436: I/com.necdisplay.IntlWirelessDataApp.common.Utility(6970): getFileList
02-03 12:59:52.961: E/WindowManager(6970): android.view.WindowLeaked: Activity com.necdisplay.IntlWirelessDataApp.serviceconnection.ServiceConnection has leaked window com.android.internal.policy.PhoneWindow$DecorView{940db25 V.E...... R......D 0,0-959,192} that was originally added here
02-03 12:59:52.961: E/WindowManager(6970): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:368)
02-03 12:59:52.961: E/WindowManager(6970): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:299)
02-03 12:59:52.961: E/WindowManager(6970): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
02-03 12:59:52.961: E/WindowManager(6970): at android.app.Dialog.show(Dialog.java:319)
02-03 12:59:52.961: E/WindowManager(6970): at com.necdisplay.IntlWirelessDataApp.common.ReadWriteTask.onPreExecute(ReadWriteTask.java:199)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:604)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.AsyncTask.execute(AsyncTask.java:551)
02-03 12:59:52.961: E/WindowManager(6970): at com.necdisplay.IntlWirelessDataApp.common.AsyncTaskForTagDetection.onPostExecute(AsyncTaskForTagDetection.java:205)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.AsyncTask.finish(AsyncTask.java:651)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.AsyncTask.-wrap1(AsyncTask.java)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.Handler.dispatchMessage(Handler.java:102)
02-03 12:59:52.961: E/WindowManager(6970): at android.os.Looper.loop(Looper.java:148)
02-03 12:59:52.961: E/WindowManager(6970): at android.app.ActivityThread.main(ActivityThread.java:5417)
02-03 12:59:52.961: E/WindowManager(6970): at java.lang.reflect.Method.invoke(Native Method)
02-03 12:59:52.961: E/WindowManager(6970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

Shared Preferences are not affected by user app permissions afaik.
Even writing files in app directory don't require permissions, according to docs https://developer.android.com/guide/topics/data/data-storage.html.
I would suspect SpecialClassMappingForSharedPreference to cause the issue.

Related

React Native App Crashes in release but works in development

I was working on an app by testing in the iOS simulator. Also I tested through a cable development version on Android. It was all good. However, when I build for production both iOS and Android crash on a specific place.
The only traces of error are the adb logcat that during/after the app crashes. I would appreciate any ideas that will help me debug the issue.
Android logs:
-14 01:30:05.000 773 1665 E dubaid : [SystemHandler.cpp] onPartialWakelockReleaseMessage# Already released, lock: 143076769
06-14 01:30:07.828 14030 14030 E JankService: child Thread receive to stop
06-14 01:30:07.940 824 1054 E JankService: all data read ok
06-14 01:30:09.302 637 3672 E audio_custom: get_config_value: invalid path /proc/device-tree/audio_hw_config/hifi_info/highperform_lowpower_support.
06-14 01:30:09.313 637 3672 E audio_hw_effect: unsupported sws effect version!
06-14 01:30:09.313 637 3672 E audio_hw_effect: sws set parameter func:[8] err: [-61]
06-14 01:30:09.318 13884 13932 E ReactNativeJS: Requiring unknown module "./locale/en-GB".
06-14 01:30:09.326 13884 13932 E ReactNativeJS: Requiring unknown module "./locale/en-gb".
06-14 01:30:09.343 13884 13933 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Process: my.bigwin.com, PID: 13884
06-14 01:30:09.343 13884 13933 E AndroidRuntime: com.facebook.react.common.JavascriptException: Requiring unknown module "./locale/en-GB"., stack:
06-14 01:30:09.343 13884 13933 E AndroidRuntime: h#2:1448
06-14 01:30:09.343 13884 13933 E AndroidRuntime: d#2:868
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Dt#861:16712
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Tt#861:17738
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Yt#861:16801
06-14 01:30:09.343 13884 13933 E AndroidRuntime: n#947:1453
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Sn#90:30120
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Or#90:45887
06-14 01:30:09.343 13884 13933 E AndroidRuntime: na#90:72881
06-14 01:30:09.343 13884 13933 E AndroidRuntime: ra#90:73371
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Oa#90:80972
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Wa#90:80310
06-14 01:30:09.343 13884 13933 E AndroidRuntime: Ue#90:83367
06-14 01:30:09.343 13884 13933 E AndroidRuntime: De#90:13673
06-14 01:30:09.343 13884 13933 E AndroidRuntime: We#90:13846
06-14 01:30:09.343 13884 13933 E AndroidRuntime: receiveTouches#90:14605
06-14 01:30:09.343 13884 13933 E AndroidRuntime: value#28:3311
06-14 01:30:09.343 13884 13933 E AndroidRuntime: <unknown>#28:822
06-14 01:30:09.343 13884 13933 E AndroidRuntime: value#28:2565
06-14 01:30:09.343 13884 13933 E AndroidRuntime: value#28:794
06-14 01:30:09.343 13884 13933 E AndroidRuntime:
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:158)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:907)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:105)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at android.os.Looper.loop(Looper.java:216)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
06-14 01:30:09.343 13884 13933 E AndroidRuntime: at java.lang.Thread.run(Thread.java:784)
06-14 01:30:09.347 824 3397 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.348 824 3397 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.348 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.349 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.349 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.357 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.358 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.362 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.364 824 6429 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.365 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.365 773 1665 E dubaid : [DubaiUtils.h] parseMessage# Failed to find second tag: uid=
06-14 01:30:09.366 773 1665 E dubaid : [SystemHandler.cpp] parsePartialWakelockAcquiredMessage# Failed to parse count: lock=20712722 tag=IntentOp:.common.broadcast.BackgroundBroadcastReceiverSupport$PersistentReceiverIntentOperation count=0
06-14 01:30:09.366 773 1665 E dubaid : [SystemHandler.cpp] onPartialWakelockAcquireMessage# Failed to parse message
06-14 01:30:09.366 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.370 773 1665 E dubaid : [SystemHandler.cpp] onPartialWakelockReleaseMessage# Already released, lock: 20712722
06-14 01:30:09.371 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.376 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.376 773 1665 E dubaid : [DubaiUtils.h] parseMessage# Failed to find second tag: uid=
06-14 01:30:09.376 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.376 773 1665 E dubaid : [SystemHandler.cpp] parsePartialWakelockAcquiredMessage# Failed to parse count: lock=7945443 tag=IntentOp:.common.broadcast.BackgroundBroadcastReceiverSupport$GmsReceiverIntentOperation count=0
06-14 01:30:09.376 773 1665 E dubaid : [SystemHandler.cpp] onPartialWakelockAcquireMessage# Failed to parse message
06-14 01:30:09.376 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.378 1231 10848 E ActivityManager: The same pid with last one, do not add dropbox and clear mLastCrashedPid. mLastAppCrashedPid==13884
06-14 01:30:09.382 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.382 773 1665 E dubaid : [SystemHandler.cpp] onPartialWakelockReleaseMessage# Already released, lock: 7945443
06-14 01:30:09.382 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.385 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.388 659 1532 E AudioFlinger: writing blocked, write to hal costs: 70 ms
06-14 01:30:09.398 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.403 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.423 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.425 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.430 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.433 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.436 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.438 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.446 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.449 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.453 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.454 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.455 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.457 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.458 1231 1753 E InputDispatcher: channel 'b8833ec my.bigwin.com/my.bigwin.com.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-14 01:30:09.459 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.459 824 6434 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.459 824 6442 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.459 824 6442 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.459 824 6442 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.460 824 6442 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.460 824 6442 E iMonitor: FaultDetect: DUMPTOOL_PRINTF return.
06-14 01:30:09.475 1231 25557 E : [ZeroHung]zrhung_get_config: Get config failed for wp[0x0110]
06-14 01:30:09.479 2088 2781 E Hicom_PolicyCenterService: handleAppDied. null == mMultipathAppsMap
06-14 01:30:09.480 2088 2104 E HsmCoreServiceImpl: onTransact in code is: 102
06-14 01:30:09.484 1231 15387 E WindowManager: win=Window{b8833ec u0 my.bigwin.com/my.bigwin.com.MainActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true
06-14 01:30:09.504 1231 1269 E libprocessgroup: Error encountered killing process cgroup uid 99036 pid 13973: No such file or directory
06-14 01:30:09.507 5645 5699 E BluetoothLeScanner: updateLeScanParams win:60 ivl:600
06-14 01:30:09.511 1544 1544 E OCTTY : [main:370] install already set to
06-14 01:30:09.511 1544 1544 E OCTTY :
06-14 01:30:09.513 2195 2503 E powergenie_jni: FUNC: setHisiCABCInner() LINE: 60 open /dev/pri_lcd error: No such file or directory
06-14 01:30:09.513 2195 2503 E DisplayControl: Fail! set cabc mode: 1
06-14 01:30:09.515 2088 2781 E XEngineMpipControl: Invalid SubId
06-14 01:30:09.519 1544 1544 E OCTTY : [main:370] install already set to
06-14 01:30:09.519 1544 1544 E OCTTY :
06-14 01:30:09.520 2088 2990 E DollieAdapterService: notifyActivityState pkg:my.bigwin.com/my.bigwin.com.MainActivity state:18 fg:false mUid:10275
06-14 01:30:09.522 2228 2312 E HwLauncher: SettingsEx , no such field.
06-14 01:30:09.538 661 3418 E BufferQueueProducer: [] mConsumerName == NULL!!!!!!
06-14 01:30:09.541 2393 2407 E : [ZeroHung]zrhung_get_config: Get config failed for wp[0x0008]
06-14 01:30:09.544 2195 3326 E AwareLog: SPKSchedFeature: Uid has been sent, ignore.
06-14 01:30:09.544 2088 31236 E HsmCoreServiceImpl: onTransact in code is: 102
06-14 01:30:09.547 2088 31236 E HsmCoreServiceImpl: onTransact in code is: 103
06-14 01:30:09.555 2088 2990 E DollieAdapterService: notifyActivityState pkg:com.huawei.android.launcher/com.huawei.android.launcher.drawer.DrawerLauncher state:2 fg:true mUid:10087
06-14 01:30:09.555 3819 3837 E AppLifeChangeSensor: CAWARENESS: activityResumed mAppLifeChangeCallback is null
06-14 01:30:09.558 1231 1938 E : [ZeroHung]zrhung_get_config: Get config failed for wp[0x0111]
06-14 01:30:09.972 1231 10719 E NetworkStats: getIfaceStats rmnet0 type 5 failed, return qtaguid stat 190962
06-14 01:30:09.972 1231 1244 E NetworkStats: getIfaceStats rmnet0 type 4 failed, return qtaguid stat 394005
I see all kinds of things, but I am unable to figure out which one causes the crash.
thanks
After all it had to do with the languages where it says Requiring unknown module "./locale/en-GB".
I fixed this and it was up and running.

calling a method in a smali file using ApplicationContext

I want to call a method using p0 ApplicationContext:Landroid/content/Context.
How can I get the ApplicationContext for the class?
I tried calling my method from the init method of the class in order to copy p0, but android failed to verify the class with this.
Any ideas? I will provide more detail if required.
#JesusFreke : More info
1 EDITED CRASH
10-06 15:43:48.081 14308 14557 E AndroidRuntime: FATAL EXCEPTION: WFSync
10-06 15:43:48.081 14308 14557 E AndroidRuntime: Process: com.zynga.words3, PID: 14308
10-06 15:43:48.081 14308 14557 E AndroidRuntime: java.lang.VerifyError: Verifier rejected class com.zynga.wfframework.appmodel.game.GameCenter$6: void com.zynga.wfframework.appmodel.game.GameCenter$6.<init>(com.zynga.wfframework.appmodel.game.GameCenter, android.content.Context, com.zynga.wfframework.appmodel.AppModelCallback, java.util.Date, long, java.util.Date, long, com.zynga.wfframework.remoteservice.IRemoteService$PollType, com.zynga.wfframework.appmodel.sync.SyncService$SyncServicePollType, android.content.Intent, int) failed to verify: void com.zynga.wfframework.appmodel.game.GameCenter$6.<init>(com.zynga.wfframework.appmodel.game.GameCenter, android.content.Context, com.zynga.wfframework.appmodel.AppModelCallback, java.util.Date, long, java.util.Date, long, com.zynga.wfframework.remoteservice.IRemoteService$PollType, com.zynga.wfframework.appmodel.sync.SyncService$SyncServicePollType, android.content.Intent, int):
[0x41] 'this' arg must be initialized
(declaration of 'com.zynga.wfframework.appmodel.game.GameCenter$6' appears in /data/app/com.zynga.words3-2/base.apk:classes3.dex)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.game.GameCenter.refreshState(SourceFile:1201)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.game.GameCenter.refreshState(SourceFile:1144)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at com.zynga.wfframework.appmodel.sync.SyncService$1.run(SourceFile:189)
10-06 15:43:48.081 14308 14557 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
2 PARTIAL CODE
.method constructor <init>(Lcom/zynga/wfframework/appmodel/game/GameCenter;Landroid/content/Context;Lcom/zynga/wfframework/appmodel/AppModelCallback;Ljava/util/Date;JLjava/util/Date;JLcom/zynga/wfframework/remoteservice/IRemoteService$PollType;Lcom/zynga/wfframework/appmodel/sync/SyncService$SyncServicePollType;Landroid/content/Intent;I)V
.registers 16
...
##41
#v0=(Reference,Lcom/zynga/wfframework/remoteservice/RemoteServiceSyncResult;);v1=(Null);p0=(UninitThis,Lcom/zynga/wfframework/appmodel/game/GameCenter$6;);
invoke-virtual {p0, v1, v0}, Lcom/zynga/wfframework/appmodel/game/GameCenter$6;->onPostExecute(ILcom/zynga/wfframework/remoteservice/RemoteServiceSyncResult;)V
Why is p0 not initialised? What can I do to catch it initialised?
Hope you can help. By the way, I fixed the problem in another way, but this relies on an error method in the class being called. I would prefer to find another solution.
In a constructor, the this argument (p0) starts out as uninitialized, and it can't be used until it has been initialized. You must call the superclass's <init> method to initialize it.
e.g. if the super class is Lcom/some/superclass;, and it has a no-args constructor, you would need to add
invoke-direct {p0}, Lcom/some/superclass;-><init>()V
at some point before you try to use p0.
Assuming you're starting out with a working method to begin with, the constructor should already have such an instruction. In which case, you just need to move your method call after it.

Server returned HTTP response code: 500 (Worklight)

I am getting HTTP response code: 500 in logs for wladmin user..because of this I am unable to deploy runtime for worklight console
[2/7/18 5:33:39:138 EST] 000000ab ServiceProxy E Received status 500 for GET https://localhost:9444/wladmin/management-apis/1.0/loginAudit
java.io.IOException: Server returned HTTP response code: 500 for URL: https://localhost:9444/wladmin/management-apis/1.0/loginAudit
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Any help?
Error log:
NDIUtils I Resource conf/jndi/default.properties not found. This is not an error. Context path is __globalscope__
[2/7/18 5:33:38:815 EST] 000000ad RuntimeServic E Failed to obtain JMX connection to access an MBean.
There might be a JMX configuration error: null
[2/7/18 5:33:39:138 EST] 000000ab ServiceProxy E Received status 500 for GET https://localhost:9444/wladmin/management-apis/1.0/loginAudit
java.io.IOException: Server returned HTTP response code: 500 for URL: https://localhost:9444/wladmin/management-apis/1.0/loginAudit
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1686)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1684)
at java.security.AccessController.doPrivileged(AccessController.java:280)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1682)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1255)
at com.ibm.net.ssl.www2.protocol.https.b.getInputStream(b.java:49)
at com.ibm.worklight.management.ui.servlet.ServiceProxy.service(ServiceProxy.java:172)
at com.ibm.worklight.management.ui.servlet.ConsoleServicesServlet.service(ConsoleServicesServlet.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1227)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:136)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:97)
at com.ibm.worklight.admin.common.filter.HSTSFilter.doFilter(HSTSFilter.java:110)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:88)
at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1784)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)

Error in deploying SQL Adapter

I am trying to deploy this SQL adapter into MobileFirst Console V8.0.0.00-20170220-1900, but it is failing with following error:
[8/18/17 16:54:23:861 CDT] 000fed6b AnalyticsConf 1 com.ibm.mfp.server.core.internal.configuration.analytics.AnalyticsConfigurationDeploymentHandler getAdditionalPackages:54 Exiting method: getAdditionalPackages() with value 'null'.
[8/18/17 16:54:23:861 CDT] 000fed6b ServiceProxy 2 com.ibm.mfp.admin.ui.servlet.ServiceProxy service Caught exception
java.io.IOException: Server returned HTTP response code: 500 for URL: http://10.80.25.54:9081/mfpadmin/management-apis/2.0/runtimes/mfp/adapters?asynch=true
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1675)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1673)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1671)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1244)
at com.ibm.mfp.admin.ui.servlet.ServiceProxy.service(ServiceProxy.java:188)
at com.ibm.mfp.admin.ui.servlet.ConsoleServicesServlet.service(ConsoleServicesServlet.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1285)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:776)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:473)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:135)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.worklight.admin.common.filter.HSTSFilter.doFilter(HSTSFilter.java:110)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:978)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1100)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:81)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:912)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: http://10.80.25.54:9081/mfpadmin/management-apis/2.0/runtimes/mfp/adapters?asynch=true
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1626)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at com.ibm.mfp.admin.ui.servlet.ServiceProxy.service(ServiceProxy.java:180)
... 19 more
[8/18/17 16:54:23:861 CDT] 000fed6b DeploymentReg 1 com.ibm.mfp.server.core.internal.deployment.registry.DeploymentRegistryImpl getAll:255 DeploymentRegistryImpl: getting all- type: com.ibm.mfp.server.core.internal.configuration.analytics.AnalyticsDynamicConfigurationImpl returned: []

SQLiteDatabase NullPointerException while querying the DB with a SELECT statement

i'm trying to query my database to check if a matching field value exists or not.
Pretty much using a SELECT sql statement.
I'm getting an NullPointerException error when i try to query the database even though the database is already open.
The following code is from the class holds all the SQLite methods:
public long createDBCard(String card_name, String card_type, String attributeType,
String summonRequirements, String card_description,
String spellSpeed, int levelStars, int rankStars, int atk_stat, int def_stat,
String setnumber, int cardNumberPass)
{
// TODO Auto-generated method stub
ContentValues cv = new ContentValues();
String passedCardName = card_name;
//long l = Long.parseLong(passedCardName);
String returnedCardName = getCardName(passedCardName);
long numCards = Countcards();
String numCardmsg = String.valueOf(numCards);
if (numCards == 51){
Toast h1 = Toast.makeText(CarddbAdapter.this, "Error counting card records.", Toast.LENGTH_LONG);
h1.show();
}else if(numCards == 0){
Toast h = Toast.makeText(this, "No cards exists", Toast.LENGTH_LONG);
h.show();
}else if(numCards >= 1){
Toast b = Toast.makeText(CarddbAdapter.this, returnedCardName, Toast.LENGTH_SHORT);
b.show();
}else{
Toast b = Toast.makeText(CarddbAdapter.this, "FAIL!!!!!!!!!!!!!!!!!", Toast.LENGTH_SHORT);
b.show();
}
cv.put(KEY_CARDNAME, card_name);
cv.put(KEY_CARDTYPE, card_type);
cv.put(KEY_ATTRIBUTETYPE, attributeType);
cv.put(KEY_SUMMONREQUIREMENTS, summonRequirements);
cv.put(KEY_CARD_DESCRIPTION, card_description);
cv.put(KEY_SPELLSPEED, spellSpeed);
cv.put(KEY_LEVELSTARS, levelStars);
cv.put(KEY_RANKSTARS, rankStars);
cv.put(KEY_ATK_STAT, atk_stat);
cv.put(KEY_DEF_STAT, def_stat);
cv.put(KEY_SETNUMBER, setnumber);
cv.put(KEY_CARDNUMBERPASS, cardNumberPass);
return ourDatabaseW.insert(DATABASE_TABLE_CARDS, null, cv);
//return 51;
}
public String getCardName(String passedName) throws SQLException{
// TODO Auto-generated method stub
String[] columns = new String[]{ KEY_CARDNAME};
Cursor c = ourDatabaseR.query(DATABASE_TABLE_CARDS, columns, KEY_CARDNAME + "='" + passedName + "'", null, null, null, null);
if (c != null){
c.moveToFirst();
String name = c.getString(0);
return name;
}
return "hello";
}
LogCat Error
05-11 01:15:49.456: E/AndroidRuntime(1509): FATAL EXCEPTION: main
05-11 01:15:49.456: E/AndroidRuntime(1509): java.lang.RuntimeException: Unable to start activity ComponentInfo{cybertech.productions.yugiohlibrary/cybertech.productions.yugiohlibrary.LoadingScreen}: java.lang.NullPointerException
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.os.Looper.loop(Looper.java:123)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-11 01:15:49.456: E/AndroidRuntime(1509): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 01:15:49.456: E/AndroidRuntime(1509): at java.lang.reflect.Method.invoke(Method.java:507)
05-11 01:15:49.456: E/AndroidRuntime(1509): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-11 01:15:49.456: E/AndroidRuntime(1509): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-11 01:15:49.456: E/AndroidRuntime(1509): at dalvik.system.NativeStart.main(Native Method)
05-11 01:15:49.456: E/AndroidRuntime(1509): Caused by: java.lang.NullPointerException
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.widget.Toast.<init>(Toast.java:89)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.widget.Toast.makeText(Toast.java:231)
05-11 01:15:49.456: E/AndroidRuntime(1509): at cybertech.productions.servicehelpers.CarddbAdapter.createDBCard(CarddbAdapter.java:144)
05-11 01:15:49.456: E/AndroidRuntime(1509): at cybertech.productions.yugiohlibrary.LoadingScreen.onCreate(LoadingScreen.java:37)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-11 01:15:49.456: E/AndroidRuntime(1509): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
05-11 01:15:49.456: E/AndroidRuntime(1509): ... 11 more
In one of my Activities i use an Object of the class to call the createDBCard() method.
Any help would be appreciated.
I tried playing around with the rawQuery() method but had errors, lol.
I fixed it, for now to where it returns my query result.
After debugging something else related to how i designed my open() method i found out, i guess from trying different things to solve some earlier errors, i declared the context as this instead of my pre-defined private final ourContext.
Below is the first debugged code that solved my later problem with my createDBCard() method, the NullPointerException.
My open() method after i declared my private final ourContext; before the DbHelper class with the rest of my other variables:
The one coded wrong below:
public CarddbAdapter open() throws SQLException{
ourHelper = new DbHelper(this);
ourDatabaseW = ourHelper.getWritableDatabase();
ourDatabaseR = ourHelper.getReadableDatabase();
return this;
}
The one coded right below:
public CarddbAdapter open() throws SQLException{
ourHelper = new DbHelper(ourContext);
ourDatabaseW = ourHelper.getWritableDatabase();
ourDatabaseR = ourHelper.getReadableDatabase();
return this;
}
As you can see i changed ourHelper = new DbHelper(this); to ourHelper = new DbHelper(ourContext);
Doing this made me realize i needed to change all the Toasts in my createDBCard() to use my pre-defined ourContext instead of this.
Thanks all for trying to help.