Android Question [Solved] Keystore Changed

Shelby

Well-Known Member
Licensed User
After making a keystore file and losing track of it, I finally discovered how to remake the keystore file and place it into the correct file i.e. One simply choses create new key in the tools/Private Sign Key window. My file is placed in: B4X/myproject/files/.keystore, etc. Now my emulator works correctly again but my phone won't display the app although the bridge seems to be correctly connected. I get the error message on the phone (B4A example window) right after it says: "Do you want to install an update to this existing application? Your data will not be lost. It does not require any special access." So I clicked install: Then it said: App not installed.
 
Last edited:

Shelby

Well-Known Member
Licensed User
Thanks Semen,
I remember reading about another member who did just that as you said with I think B4i. I didn't know that I could also ignore the keystore with B4A. Oh well, live and learn (sometimes get burned).
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Hmm, It seems to have straightened itself out now. My S9 is displaying the app nicely..... Whoops! It only displays slowly in debug mode. Then in release mode, it doesn't display. The emulator seems to be functioning normally.
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Finding the thread: https://www.b4x.com/android/forum/threads/bridgecli-command-line-tool-for-b4a-bridge.76536/#content
I downloaded the zip file "B4A-Bridge_CLI" and extracted it into my project folder.
I also have pasted the line: "#BridgeLogger: True" into my code in the activity area. Initially I had results but not in release mode. Now even the debugger mode won't give me results. I'm also getting no logs output. Any suggestions? My emulator is still operating properly but with no logs showing in my API.

Here's my project:


B4X:
#Region  Project Attributes
    #ApplicationLabel: AreaCalc
    #VersionCode:14
    #VersionName:
   
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: True
   
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules. Public by default.SSS
   
   
   
    Public TotalArea As Double
    Type Rooms(Width As Double, Length As Double, Area As Double)
    Public lstRooms As List
    Public RoomIndex = 1 As Int
End Sub

Sub Globals
    'Variables always Private in this sub SSS
   
    Private lblRoom, lblFind, lblArea, lblTotalArea, lblRoomNumber As Label
    Private edtLen, edtWidth As EditText
    Private btnCalc As Button
    'Private pnlBitmap As Panel
       
    Private ltvRooms As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Room1_")
    #BridgeLogger: True
   
    lstRooms.Initialize
    ltvRooms.SingleLineLayout.Label.TextSize = 18
    ltvRooms.SingleLineLayout.ItemHeight = 30dip
   
    NewRoom
   
   

'    pnlBitmap.Initialize ("")
'    Activity.AddView (pnlBitmap, 0%x, 270dip, 72%y, 190dip)
'    Private bdwBitmap As BitmapDrawable
'    bdwBitmap.Initialize(LoadBitmap(File.DirAssets, "Framing.jpg"))
'    bdwBitmap.Gravity = Gravity.FILL
'    pnlBitmap.Background = bdwBitmap  
   
    Log($"Today's Date  $date{DateTime.Now}"$)
    'Above is  smart string (using $ symbols)
   
    'Not smart
    Log("Also today is " & DateUtils.GetDayOfWeekName(DateTime.Now))
    '***
   
   
    'Below is smart string time
    Log ($"The Time $Time{DateTime.Now}"$)
           
End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)
   
End Sub

Private Sub NewRoom
    Private Room As Rooms
    Room.Area = 0
    Room.Length = 0
    Room.Width = 0
    lstRooms.Add(Room)
    ltvRooms.AddSingleLine("Room #" & RoomIndex & "  L = " & Room.Width  & "   W = " & Room.Length& " Area = " & NumberFormat(Room.Area, 1, 2))
    RoomIndex = lstRooms.Size
   
    lblArea.Text = " Enter Dimensions Below"
End Sub

Sub btnCalc_Click
    Private Room As Rooms
    Room.Width = edtWidth.Text
    Room.Length = edtLen.Text
    Room.Area = Room.Width * Room.Length
    TotalArea = TotalArea + Room.Area
    lblArea.Text = NumberFormat(Room.Area, 1, 0)  & "  Square Feet"
    lstRooms.Set(RoomIndex - 1, Room)
    UpdateRoomList
    CalculateTotalArea
    lblTotalArea.Text = NumberFormat(TotalArea, 1, 2) & "   s.f."
'    Log(Result & " Sq Ft")
End Sub

Private Sub btnNewRoom_Click
    NewRoom
    UpdateNewRoomScreen
    UpdateRoomList
End Sub

Sub ltvRooms_ItemClick (Position As Int, Value As Object)
    RoomIndex = Position  + 1
    UpdateRoomScreen
End Sub

Private Sub UpdateRoomScreen
    Private Room As Rooms
   
    Room = lstRooms.Get(RoomIndex - 1)
    lblRoomNumber.Text = RoomIndex
    If Room.Width = 0 Then
        edtWidth.Text = ""
    Else
        edtWidth.Text = Room.Width
    End If
    If Room.Length = 0 Then
        edtLen.Text = ""
    Else
        edtLen.Text = Room.Length
    End If
    lblArea.Text =  NumberFormat(Room.Area, 1, 0) & " Square Feet"
    lblTotalArea.Text = NumberFormat(TotalArea, 1, 2)
End Sub

Private Sub UpdateNewRoomScreen
    lblRoomNumber.Text = RoomIndex
    edtWidth.Text = ""
    edtLen.Text = ""
End Sub

Private Sub UpdateRoomList
    Private i As Int
   
    ltvRooms.Clear
    For i = 0 To lstRooms.Size - 1
        Private Room As Rooms
        Room = lstRooms.Get(i)
        ltvRooms.AddSingleLine("Room #" & (i + 1) & "  W = " & Room.Width  & "   L = " & Room.Length & " Area = " & NumberFormat(Room.Area, 1, 2))
    Next
End Sub

Private Sub CalculateTotalArea
    Private i As Int
   
    TotalArea = 0
    For i = 0 To lstRooms.Size - 1
        Private Room As Rooms
        Room = lstRooms.Get(i)
        TotalArea = TotalArea + Room.Area
       
        Log (TotalArea)
       
    Next
End Sub
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Here's my log when I try to display my app in Release mode with the '#BridgeLogger: True' line properly installed :


B4X:
Logger connected to:  samsung SM-G960U
--------- beginning of crash
--------- beginning of main
Copying updated assets files (8)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:17:12
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:17:31
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:21:14
** Activity (main) Resume **
1
1
5
1
5
21
1
5
21
37
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:24:03
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
java.lang.RuntimeException: Unable to create service b4a.AreaCalc.starter: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3740)
    at android.app.ActivityThread.access$1400(ActivityThread.java:235)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6981)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at b4a.AreaCalc.starter.onCreate(starter.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3728)
    ... 8 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:124)
    ... 12 more
Logger connected to:  samsung SM-G960U
--------- beginning of crash
--------- beginning of main
Copying updated assets files (8)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:17:12
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:17:31
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:21:14
** Activity (main) Resume **
1
1
5
1
5
21
1
5
21
37
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Today's Date  09/27/2019
Also today is Friday
The Time 07:24:03
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
java.lang.RuntimeException: Unable to create service b4a.AreaCalc.starter: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3740)
    at android.app.ActivityThread.access$1400(ActivityThread.java:235)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1784)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6981)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:164)
    at anywheresoftware.b4a.shell.Shell.start(Shell.java:102)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:92)
    at b4a.AreaCalc.starter.onCreate(starter.java:34)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3728)
    ... 8 more
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference
    at anywheresoftware.b4a.shell.ShellConnector.sendControlMessage(ShellConnector.java:61)
    at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:124)
    ... 12 more

I don't think I know how to decipher these messages. Even if I partially understand the messages, I don't know how I might act to rectify any problems. Any suggestions?
Thanks
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
This seems to be the problem:

B4X:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.OutputStream.write(byte[])' on a null object reference

I don't understand how to analyze and solve this problem. I don't know what a null object is so I'll try researching it and how to deal with it.
 
Last edited:
Upvote 0

Shelby

Well-Known Member
Licensed User
Seemingly solved:
This morning after reading the thread:
https://www.b4x.com/android/forum/threads/changing-package-name.77266/

The issue seems to no longer exist after I changed the package name in the IDE- project>build configuration. I simply added 9_30 to the end of the existing package name. Now my phone quickly loads my app.
Thanks Sorex.........!

Also thanks Erel for the shortcut to change the package name while in the IDE: Cntrl+B
 
Last edited:
Upvote 0
Top