Android Question After deleting the objects folder for solving 'Access Path denied' ,it can installed,but it can't runned.

Theera

Expert
Licensed User
Longtime User
Hi all,
I have a same problem , and solving as following the expert's . The app can installed at the frist time,but it can't runned.
How to solve the problem? My project about B4A-Bridge for Thai Delvelopers and I for learning code (its code from Aeric's code)
I've test another app,the result is the same( it can't run)

attach file here
 
Last edited:

Theera

Expert
Licensed User
Longtime User
Can you post the full text from the compilation window?
B4A Version: 13.40
Parsing code. (0.40s)
Java Version: 19
Building folders structure. (0.61s)
Compiling code. (1.34s)
Compiling layouts code. (0.03s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Compiling resources (4.48s)
Linking resources (21.93s)
build tools: 36.0.0, android jar: android-36
Compiling debugger engine code. (0.10s)
Compiling generated Java code. (0.52s)
Finding libraries that need to be dexed. (0.07s)
Dex code (4.08s)
Dex merge (18.38s)
Copying libraries resources (3.42s)
ZipAlign file. (0.70s)
Signing package file (debug key). (5.11s)
Installing file to device. (0.38s)
Installing with B4A-Bridge.
Completed successfully.

It's running compiling completed,but It can't run
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I tried the project.

My B4A Logs show:
B4X:
Logger connected to:  HONOR VNE-LX2
--------- beginning of main
Copying updated assets files (16)
*** Service (starter) Create ***
Error opening auto discover port
(ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
17
** Activity (main) Pause, UserClosed = false **
Sleep not resumed (context is paused): anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub
*** Service (service1) Create ***
android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error occurred on line: 92 (Service1)
java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=*** shortcut=null contentView=null vibrate=null sound=null defaults=0xfffffffc flags=0x0 color=0x00000000 vis=PRIVATE)
    at android.app.NotificationManager.fixNotification(NotificationManager.java:715)
    at android.app.NotificationManager.notifyAsUser(NotificationManager.java:694)
    at android.app.NotificationManager.notify(NotificationManager.java:643)
    at android.app.NotificationManager.notify(NotificationManager.java:619)
    at anywheresoftware.b4a.objects.NotificationWrapper.Notify(NotificationWrapper.java:284)
    at com.puterise.b4abridge.service1._updatenotification(service1.java:1044)
    at com.puterise.b4abridge.service1._service_create(service1.java:977)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.puterise.b4abridge.service1.onCreate(service1.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5541)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2886)
    at android.os.Handler.dispatchMessage(Handler.java:117)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:302)
    at android.app.ActivityThread.main(ActivityThread.java:9652)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1062)
** Service (service1) Start **

Error #1: (ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error #1 in Starter service:
Sub Service_Create
   
    folder = rp.GetSafeDirDefaultExternal("")
    If folder = File.DirInternal Then
        ToastMessageShow("Secondary storage is not available. You will need to switch to USB debug mode.", True)
    End If
    Try
        AutoDiscoverUdpSocket.Initialize("AutoDiscoverUdpSocket", 58912, 8192)
    Catch
        Log("Error opening auto discover port")
        Log(LastException)
    End Try
    AcquireMulticastLock
End Sub

Error #2: android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error #2 in Service1 service:
Sub Service_Create
   
    Try
        If WifiServer.IsInitialized = False Then
            WifiServer.Initialize(6789, "Server")
        End If
    Catch
        Log(LastException.Message)
        'switch to alternate port
        WifiServer.Initialize(6789 + 117, "Server")
    End Try
    If Phone.SdkVersion >= 16 And UdpServer.IsInitialized = False Then
        UdpServer.Initialize("Udp", 0, 8192)
    End If
    DisconnectTimer.Initialize("DisconnectTimer", 1000)
   
    PE.Initialize("PE")
    UpdateNotification
    Service.StartForeground(1, Notification1)
    Try
        SetFTPServerState
    Catch
        Log(LastException)
    End Try
   
End Sub

For error #1 and #2, I think because B4a-Bridge already running using a port number. I tried to change the port number.

Error #3: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=*** shortcut=null contentView=null vibrate=null sound=null defaults=0xfffffffc flags=0x0 color=0x00000000 vis=PRIVATE)
Error #3 in Service1 service:
Private Sub UpdateNotification
    Dim icon As String
    Dim content As String
    If ConnectedStatus Then
        icon = "a_connected"
        content = "Connected"
    Else
        icon = "a_disconnected"
        content = "Disconnected"
    End If
    Notification1.Initialize2(Notification1.IMPORTANCE_LOW)
    Notification1.Sound = False
    Notification1.Vibrate = False
    Notification1.Icon = icon
    Notification1.SetInfo("B4A-Bridge", content, Main)
    Notification1.Notify(1)
End Sub

Solution #1 (error #3)

Let me fix this error first.
It seems the project is missing the following files:
a_connected.png
a_disconnected.png


Just put back these 2 files to B4A-Bridge267e\Objects\res\drawable
1762859457318.png


After fixing error #3, it is still showing error and I find the code actually handle the alternate port number.
B4X:
    Try
        If WifiServer.IsInitialized = False Then
            WifiServer.Initialize(6789, "Server")
        End If
    Catch
        Log(LastException.Message)
        'switch to alternate port
        WifiServer.Initialize(6789 + 117, "Server")
    End Try

Then I found the error #4.
B4X:
Logger connected to:  HONOR VNE-LX2
--------- beginning of main
*** Service (starter) Create ***
Error opening auto discover port
(ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
17
*** Service (service1) Create ***
Error occurred on line: 53 (Service1)
android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{6188154 27609:com.puterise.b4abridge/u0a393} targetSDK=35
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
    at android.os.Parcel.readParcelableInternal(Parcel.java:4890)
    at android.os.Parcel.readParcelable(Parcel.java:4872)
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3072)
    at android.os.Parcel.createException(Parcel.java:3061)
    at android.os.Parcel.readException(Parcel.java:3044)
    at android.os.Parcel.readException(Parcel.java:2986)
    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6833)
    at android.app.Service.startForeground(Service.java:781)
    at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85)
    at com.puterise.b4abridge.service1._service_create(service1.java:980)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.puterise.b4abridge.service1.onCreate(service1.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5541)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2886)
    at android.os.Handler.dispatchMessage(Handler.java:117)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:302)
    at android.app.ActivityThread.main(ActivityThread.java:9652)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1062)
** Service (service1) Start **

Solution #2 (error #1 and #2)

It seems the errors are related to Foreground service types

It means we need to update the Manifest editor.
The easiest way is to check Erel's source code for B4A Bridge here:
which is hosted on GitHub and by observing the xml file here: https://github.com/AnywhereSoftware/B4A-Bridge/blob/main/Objects/AndroidManifest.xml

I guess I need to add the following to the Manifest Editor:
B4X:
AddPermission(android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE)
SetServiceAttribute(service1, android:foregroundServiceType, "connectedDevice")

So the app is now compile and run on my phone.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
I tried the project.

My B4A Logs show:
B4X:
Logger connected to:  HONOR VNE-LX2
--------- beginning of main
Copying updated assets files (16)
*** Service (starter) Create ***
Error opening auto discover port
(ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
17
** Activity (main) Pause, UserClosed = false **
Sleep not resumed (context is paused): anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub
*** Service (service1) Create ***
android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error occurred on line: 92 (Service1)
java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=*** shortcut=null contentView=null vibrate=null sound=null defaults=0xfffffffc flags=0x0 color=0x00000000 vis=PRIVATE)
    at android.app.NotificationManager.fixNotification(NotificationManager.java:715)
    at android.app.NotificationManager.notifyAsUser(NotificationManager.java:694)
    at android.app.NotificationManager.notify(NotificationManager.java:643)
    at android.app.NotificationManager.notify(NotificationManager.java:619)
    at anywheresoftware.b4a.objects.NotificationWrapper.Notify(NotificationWrapper.java:284)
    at com.puterise.b4abridge.service1._updatenotification(service1.java:1044)
    at com.puterise.b4abridge.service1._service_create(service1.java:977)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.puterise.b4abridge.service1.onCreate(service1.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5541)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2886)
    at android.os.Handler.dispatchMessage(Handler.java:117)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:302)
    at android.app.ActivityThread.main(ActivityThread.java:9652)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1062)
** Service (service1) Start **

Error #1: (ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error #1 in Starter service:
Sub Service_Create
 
    folder = rp.GetSafeDirDefaultExternal("")
    If folder = File.DirInternal Then
        ToastMessageShow("Secondary storage is not available. You will need to switch to USB debug mode.", True)
    End If
    Try
        AutoDiscoverUdpSocket.Initialize("AutoDiscoverUdpSocket", 58912, 8192)
    Catch
        Log("Error opening auto discover port")
        Log(LastException)
    End Try
    AcquireMulticastLock
End Sub

Error #2: android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
Error #2 in Service1 service:
Sub Service_Create
 
    Try
        If WifiServer.IsInitialized = False Then
            WifiServer.Initialize(6789, "Server")
        End If
    Catch
        Log(LastException.Message)
        'switch to alternate port
        WifiServer.Initialize(6789 + 117, "Server")
    End Try
    If Phone.SdkVersion >= 16 And UdpServer.IsInitialized = False Then
        UdpServer.Initialize("Udp", 0, 8192)
    End If
    DisconnectTimer.Initialize("DisconnectTimer", 1000)
 
    PE.Initialize("PE")
    UpdateNotification
    Service.StartForeground(1, Notification1)
    Try
        SetFTPServerState
    Catch
        Log(LastException)
    End Try
 
End Sub

For error #1 and #2, I think because B4a-Bridge already running using a port number. I tried to change the port number.

Error #3: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=*** shortcut=null contentView=null vibrate=null sound=null defaults=0xfffffffc flags=0x0 color=0x00000000 vis=PRIVATE)
Error #3 in Service1 service:
Private Sub UpdateNotification
    Dim icon As String
    Dim content As String
    If ConnectedStatus Then
        icon = "a_connected"
        content = "Connected"
    Else
        icon = "a_disconnected"
        content = "Disconnected"
    End If
    Notification1.Initialize2(Notification1.IMPORTANCE_LOW)
    Notification1.Sound = False
    Notification1.Vibrate = False
    Notification1.Icon = icon
    Notification1.SetInfo("B4A-Bridge", content, Main)
    Notification1.Notify(1)
End Sub

Solution #1 (error #3)

Let me fix this error first.
It seems the project is missing the following files:
a_connected.png
a_disconnected.png


Just put back these 2 files to B4A-Bridge267e\Objects\res\drawable
View attachment 168266

After fixing error #3, it is still showing error and I find the code actually handle the alternate port number.
B4X:
    Try
        If WifiServer.IsInitialized = False Then
            WifiServer.Initialize(6789, "Server")
        End If
    Catch
        Log(LastException.Message)
        'switch to alternate port
        WifiServer.Initialize(6789 + 117, "Server")
    End Try

Then I found the error #4.
B4X:
Logger connected to:  HONOR VNE-LX2
--------- beginning of main
*** Service (starter) Create ***
Error opening auto discover port
(ErrnoException) android.system.ErrnoException: bind failed: EADDRINUSE (Address already in use)
** Service (starter) Start **
** Activity (main) Create (first time) **
** Activity (main) Resume **
17
*** Service (service1) Create ***
Error occurred on line: 53 (Service1)
android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{6188154 27609:com.puterise.b4abridge/u0a393} targetSDK=35
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
    at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
    at android.os.Parcel.readParcelableInternal(Parcel.java:4890)
    at android.os.Parcel.readParcelable(Parcel.java:4872)
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3072)
    at android.os.Parcel.createException(Parcel.java:3061)
    at android.os.Parcel.readException(Parcel.java:3044)
    at android.os.Parcel.readException(Parcel.java:2986)
    at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6833)
    at android.app.Service.startForeground(Service.java:781)
    at anywheresoftware.b4a.objects.ServiceHelper.StartForeground(ServiceHelper.java:85)
    at com.puterise.b4abridge.service1._service_create(service1.java:980)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at com.puterise.b4abridge.service1.onCreate(service1.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:5541)
    at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2886)
    at android.os.Handler.dispatchMessage(Handler.java:117)
    at android.os.Looper.loopOnce(Looper.java:210)
    at android.os.Looper.loop(Looper.java:302)
    at android.app.ActivityThread.main(ActivityThread.java:9652)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1062)
** Service (service1) Start **

Solution #2 (error #1 and #2)

It seems the errors are related to Foreground service types

It means we need to update the Manifest editor.
The easiest way is to check Erel's source code for B4A Bridge here:
which is hosted on GitHub and by observing the xml file here: https://github.com/AnywhereSoftware/B4A-Bridge/blob/main/Objects/AndroidManifest.xml

I guess I need to add the following to the Manifest Editor:
B4X:
AddPermission(android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE)
SetServiceAttribute(service1, android:foregroundServiceType, "connectedDevice")

So the app is now compile and run on my phone.
within objects folder , there is res folder and within res folder, you have mdlp folder(I can't remember ) which there are pictures ofpng files.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
within objects folder , there is res folder and within res folder, you have mdlp folder(I can't remember ) which there are pictures ofpng files.
I already showed you, it is same folder as the app icon.png (drawable)
 
Upvote 0
Top