Droid-ify / client

F-Droid client with Material UI.
GNU General Public License v3.0
3.94k stars 82 forks source link

[BUG] Crash due to Downloader failed to initialized at Application initializing #432

Closed chr56 closed 1 year ago

chr56 commented 1 year ago

Describe the bug Crash at Startup (Application.onCreate()), due to Downloader failed to initialized/injected by hilt because of network(?).

Crash Report

[OS]: DerfFest
[OS Version]: 13-Official-Tango-picasso-20230725-1349
[Device Model]: picasso (Redmi K30 5G)
[Display]: TQ3A.230705.001
[Android Version]: 13
[Android API Level]: 33
[System Locale]: zh_SG_#Hans
[Process ID]: 31198
[CPU ABI]: none
[Package Name]: com.looker.droidify
[Version Name]: 0.5.8.1
[Version Code]: 581
[Error Type]: JVM
[Crash Time]: 2023-08-21T08:38:21.575
[Stack Trace]:
java.lang.RuntimeException: Unable to create application com.looker.droidify.MainApplication: android.os.NetworkOnMainThreadException
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6839)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7969)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
Caused by: android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1676)
    at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:115)
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
    at java.net.InetAddress.getByName(InetAddress.java:1106)
    at java.net.InetSocketAddress.<init>(InetSocketAddress.java:235)
    at com.looker.droidify.DaggerMainApplication_HiltComponents_SingletonC$SingletonCImpl$SwitchingProvider.get(SourceFile:85)
    at dagger.internal.DoubleCheck.get(SourceFile:14)
    at com.looker.droidify.DaggerMainApplication_HiltComponents_SingletonC$SingletonCImpl.ktorDownloader(Unknown Source:4)
    at com.looker.droidify.Hilt_MainApplication.onCreate(SourceFile:39)
    at com.looker.droidify.MainApplication.onCreate(SourceFile:3)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1293)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6834)
    ... 9 more

To Reproduce Launch the application.

chr56 commented 1 year ago

This happened at constructing com.looker.network.KtorDownloader, which need a io.ktor.client.HttpClient but it failed to construct by hilt:

DaggerMainApplication_HiltComponents_SingletonC$SingletonCImpl.smali.gz at line 463 (decompiled by jadx: DaggerMainApplication_HiltComponents_SingletonC$SingletonCImpl.java.gz at line 102). The java.net.InetSocketAddress is failed to constructed.

chr56 commented 1 year ago

By the way, can we postpone the initializing of Downloader? Or move out from MainApplication? We at least need to "let app launched".

Iamlooker commented 1 year ago

This has been fixed and will be available in next update. Teat build is live on telegram channel.