Android Question R8 - code now crashing

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Code:
Get this crash Info

java.lang.NullPointerException
        at com.BOBs.BOBsCommon.cdropdown._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(SourceFile:32)
        at com.BOBs.BOBsCommon.cdropdown._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv4(SourceFile:273)

cdropdown line 32 says what?
public anywheresoftware.b4a.objects.B4XViewWrapper _vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv5 = null;

This make no sense to me
so I go to line 273 to see what is there
@Override
        public String toString() {
            return BA.TypeToString(this, false);
        }}
public void  _add_item(com.BOBs.BOBsCommon.cdropdown._tdropdown_itementry _itementry) throws Exception{
ResumableSub_Add_Item rsub = new ResumableSub_Add_Item(this,_itementry);
rsub.resume(ba, null);
}
The string to string does not mean anything but _add_item??

This only happen when I compile with #R8 option (probably something I did wrong years ago coming back to haunt me)

not sure how to debug (i was crashing somewhere else) until I recompiled this library with #r8 options. (not sure if this helps)

Final note this is code that has been running file (not saying it isn't my error - just how to shoot these is a problem
 
Hmm, you can try adding this to the manifest file.

I would personally go with this line.
B4X:
AddProguardText(
-keep class com.BOBs.BOBsCommon.cdropdown { *; }
)

Or maybe even this.
B4X:
AddProguardText(
  -keep class com.BOBs.BOBsCommon.** { *; }
)

I doubt any of the lines above will fix your issue though...
 
Upvote 0
no. didn't help.

I believe the routine below is where it is happening

if (BA.isShellModeRuntimeCheck(ba))
this.getClass().getMethod("_class_globals", com.BOBs.BBS.cdropdown.class).invoke(this, new Object[] {null});
else

Code:
public class cdropdown extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new BA(_ba, this, htSubs, "com.BOBs.BBS.cdropdown");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba))
               this.getClass().getMethod("_class_globals", com.BOBs.BBS.cdropdown.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }
 
Upvote 0
Sorry, didn't realize I could use #r8 with debug.

its crashing on this line
mTypesDropDown.Initialize(Root, Me, "TypesList", True, IsSmallScreen)

mTyesDropDown is defined as
Private mTypesDropDown As cDropDown

it never even steps into the Initializer
Code:
Public  Sub Initialize(xRoot As B4XView, xCallRoutine As Object, xCallFunction As String, xNarrowBitmaps As Boolean, xSmallScreen As Boolean)
   
            mHideKB            = Null
           
            mRoot = xRoot
           
            mDDListItems.Initialize

            mLastSelected        = -1
            mPreviousSelected     = -1
            gNarrowBitmaps      = xNarrowBitmaps
            gSmallScreen        = xSmallScreen
           
           
            If  cRelativePosition.IsInitialized = False Then cRelativePosition.Initialize
            If  mT8TextSize.IsInitialized        = False Then mT8TextSize.Initialize
           
            InitializeCommon(mRoot, xCallRoutine, xCallFunction, xNarrowBitmaps)
End Sub

Code:
pPrizeFund::Initialize
pBilling::Initialize
pScoreCollectors::Initialize
Cuts Panel Top  Small P:867
Error occurred on line: 1082 (pPrizeFund)
java.lang.NullPointerException
    at R1.a.a(SourceFile:12)
    at com.BOBs.BOBsCommon.cdropdown._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(SourceFile:21)
    at com.BOBs.BOBsCommon.cdropdown._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv4(SourceFile:273)
    at com.BOBs.BOBsCommon.cdropdown._initialize(SourceFile:46)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(SourceFile:43)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(SourceFile:380)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(SourceFile:12)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(SourceFile:264)
    at anywheresoftware.b4a.debug.Debug.delegate(SourceFile:9)
    at com.BOBs.BBS.pprizefund._create_screen_common(SourceFile:28)
    at com.BOBs.BBS.pprizefund$ResumableSub_Create_Screen.resume(SourceFile:38)
    at com.BOBs.BBS.pprizefund._create_screen(SourceFile:49)
    at com.BOBs.BBS.pprizefund$ResumableSub_UI_Create.resume(SourceFile:77)
    at com.BOBs.BBS.pprizefund._ui_create(SourceFile:49)
    at com.BOBs.BBS.pprizefund$ResumableSub_B4XPage_Resize.resume(SourceFile:270)
    at com.BOBs.BBS.pprizefund._b4xpage_resize(SourceFile:46)
    at com.BOBs.BBS.pprizefund._b4xpage_created(SourceFile:57)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(SourceFile:138)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(SourceFile:7)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(SourceFile:43)
    at com.BOBs.BBS.b4xpagesmanager._createpageifneeded(SourceFile:106)
    at com.BOBs.BBS.b4xpagesmanager._addpageandcreate(SourceFile:51)
    at com.BOBs.BBS.b4xpages._addpageandcreate(SourceFile:42)
    at com.BOBs.BBS.b4xmainpage$ResumableSub_B4XPage_Resize.resume(SourceFile:1142)
    at com.BOBs.BBS.b4xmainpage._b4xpage_resize(SourceFile:46)
    at com.BOBs.BBS.b4xmainpage$ResumableSub_B4XPage_Created.resume(SourceFile:300)
    at com.BOBs.BBS.b4xmainpage._b4xpage_created(SourceFile:35)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(SourceFile:138)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(SourceFile:7)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(SourceFile:43)
    at com.BOBs.BBS.b4xpagesmanager._createpageifneeded(SourceFile:106)
    at com.BOBs.BBS.b4xpagesmanager._showpage(SourceFile:63)
    at com.BOBs.BBS.b4xpagesmanager._addpage(SourceFile:121)
    at com.BOBs.BBS.b4xpagesmanager._addpageandcreate(SourceFile:39)
    at com.BOBs.BBS.b4xpagesmanager._initialize(SourceFile:296)
    at com.BOBs.BBS.main$ResumableSub_SignedIn_Complete.resume(SourceFile:104)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(SourceFile:10)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(SourceFile:115)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(SourceFile:344)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(SourceFile:12)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(SourceFile:264)
    at anywheresoftware.b4a.BA.raiseEvent(SourceFile:7)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(SourceFile:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(SourceFile:45)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(SourceFile:227)
    at anywheresoftware.b4a.BA.raiseEvent(SourceFile:7)
    at anywheresoftware.b4a.keywords.Common$15.run(SourceFile:19)
    at android.os.Handler.handleCallback(Handler.java:1070)
    at android.os.Handler.dispatchMessage(Handler.java:125)
    at android.os.Looper.dispatchMessage(Looper.java:358)
    at android.os.Looper.loopOnce(Looper.java:288)
    at android.os.Looper.loop(Looper.java:392)
    at android.app.ActivityThread.main(ActivityThread.java:10346)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972)
Message longer than Log limit (4000). Message was truncated.

I cannot step into the Initialize routine - doesn't seem to like the parameters I am passing?

Attaching JavaCode for cDropDown

Tried in all release mode and fails when using #r8 - otherwise works fine.
 

Attachments

Upvote 0
it was in a library. pulled it out to debug the problem

I attached the complete program. Wrote this probably 10 years ago before we had one on the site and before all the good designer stuff

has always work perfectly
Code:
            mTypesDropDown.Initialize(Root, Me, "TypesList", True, IsSmallScreen)
            mTypesDropDown.SetBorderFrame(mTypesDropDown.MakeTDropDown_Border(cColors.White, 5dip, 3dip, cColors.DarkGray))                     
            mTypesDropDown.SetListInfo(mTypesDropDown.MakeTDropDown_Text(5dip, 18, cColors.Gray, cColors.White, Typeface.DEFAULT_BOLD, Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)))
            mTypesDropDown.SetDisplayInfo(mTypesDropDown.MakeTDropDown_Text(15dip, 22, cColors.White, cColors.Blue, Typeface.CreateNew(Typeface.DEFAULT, Typeface.STYLE_ITALIC), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)))                                                           
            mTypesDropDown.Attach(sSP_TypesList)     
            
    It's creating a dropdown list and attaching it to a Panel "sSP_TypesList"

Screen Shots
 

Attachments

  • cDropDown.bas
    cDropDown.bas
    96.9 KB · Views: 53
  • Screenshot_20261005_110307.jpg
    Screenshot_20261005_110307.jpg
    410.9 KB · Views: 56
  • Screenshot_20261005_110312.jpg
    Screenshot_20261005_110312.jpg
    390.7 KB · Views: 66
Upvote 0
Back
Top