itkach / aard2-android

Aard2 for Android, a simple dictionary app
GNU General Public License v3.0
425 stars 98 forks source link

Crashes on start if not given network permissions #173

Closed robsmith11 closed 6 months ago

robsmith11 commented 6 months ago

I installed the F-Droid build of Aard 2 on my Pixel 7 Pro with GrapheneOS (Android 14). It works fine when given network permissions, but without that it immediately crashes with:

type: crash
osVersion: google/cheetah/cheetah:14/UP1A.231105.003/2023120400:user/release-keys
package: itkach.aard2:54
process: itkach.aard2
processUptime: 107 + 238 ms
installer: com.android.packageinstaller

java.lang.RuntimeException: Unable to create application itkach.aard2.Application: java.lang.RuntimeException: Failed to start web server
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7025)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2243)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.app.ActivityThread.main(ActivityThread.java:8199)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    at com.android.internal.os.ExecInit.main(ExecInit.java:49)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: java.lang.RuntimeException: Failed to start web server
    at itkach.aard2.Application.startWebServer(Application.java:220)
    at itkach.aard2.Application.onCreate(Application.java:112)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1321)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7020)
    ... 11 more
Caused by: java.net.SocketException: Permission denied
    at sun.nio.ch.Net.socket0(Native Method)
    at sun.nio.ch.Net.serverSocket(Net.java:424)
    at sun.nio.ch.ServerSocketChannelImpl.<init>(ServerSocketChannelImpl.java:88)
    at sun.nio.ch.SelectorProviderImpl.openServerSocketChannel(SelectorProviderImpl.java:56)
    at java.nio.channels.ServerSocketChannel.open(ServerSocketChannel.java:113)
    at org.simpleframework.transport.connect.SocketAcceptor.<init>(SocketAcceptor.java:95)
    at org.simpleframework.transport.connect.SocketListener.<init>(SocketListener.java:81)
    at org.simpleframework.transport.connect.SocketListenerManager.listen(SocketListenerManager.java:98)
    at org.simpleframework.transport.connect.SocketListenerManager.listen(SocketListenerManager.java:81)
    at org.simpleframework.transport.connect.SocketConnection.connect(SocketConnection.java:106)
    at itkach.slobber.Slobber.start(Slobber.java:578)
    at itkach.aard2.Application.startWebServer(Application.java:210)
    ... 14 more
itkach commented 6 months ago

The app uses embedded web server, which by the looks of it can't work without network permissions (even if it only listens on localhost), so this is not optional.

robsmith11 commented 6 months ago

Shouldn't the app fail more gracefully with a message saying it needs network permissions rather than silently crash?

It's not obvious to a user that a local dictionary app would need to run a web server..

itkach commented 6 months ago

Shouldn't the app fail more gracefully with a message saying it needs network permissions rather than silently crash?

It should. I wonder though, how does one go about revoking this particular permission? System settings in Android 14 say "No permissions granted"

image

Tap "Permissions" to get to the detail screen, the go to menu, select "All permissions" - this finally opens the screen where "have full network access" is listed under "other app capabilities". There is no option to remove these "app capabilities".

image
robsmith11 commented 6 months ago

Screenshot_20231225-124546_Settings

I guess optional network permissions are not standard for Android and only available because I'm using GrapheneOS. Feel free to close if that's the case.