sAleksovski / react-native-android-widget

Build Android Widgets with React Native
https://sAleksovski.github.io/react-native-android-widget/
MIT License
546 stars 22 forks source link

Click action is not working #52

Closed RohitBansal272 closed 6 months ago

RohitBansal272 commented 7 months ago

When the app is in kill state and I am clicking on a view with clickaction, it does nothing. To make it work I have to open the app and click on that view again.

Any solution for this?

sAleksovski commented 7 months ago

Dev mode or production?

What is your clickAction?

I just tried with the apk from Releases and it works when I kill the app.

Rohit3523 commented 7 months ago

It is happening in production build

clickAction is a custom string

It is working with the apk mentioned in the release section

sAleksovski commented 7 months ago

What version of the library are you using? How are you handling the clickAction?

Can you compare to see what is different in your widget, and the widget in which it works from the sampleapp?

Rohit3523 commented 7 months ago

react-native: 0.72.3 react-native-android-widget: 0.8.2

if(props.widgetAction === "WIDGET_CLICK"){
       if(props.clickAction === "refresh_widget"){
             //It get the token from async storage
             //call api

            props.renderWidget(<Widget data={cbaData} />);
       }
}
Rohit3523 commented 7 months ago

Same code works when i launch app and click on same area

sAleksovski commented 7 months ago

Can it be related to the token/api call? Can you try without it to make sure it works?

Are you getting any errors? Can you check logcat logs? You can enable them for a production build https://stackoverflow.com/questions/25610936/enable-logcat-on-release-build-in-android-studio

Rohit3523 commented 7 months ago

api is giving response when i try to call it in postman

Let me enable logcat and check in it

Rohit3523 commented 7 months ago

I get this in log when i click the widget first time after killing it

11-22 23:42:44.709  1660  1701 I ActivityManager: Start proc 16548:com.minocular.dcw/u0a867 for broadcast {com.minocular.dcw/com.minocular.dcw.widget.CBAWidget} caller=com.minocular.dcw
11-22 23:42:44.816  3257 29283 W MQSService: CallerName:com.minocular.dcw,calling Uid:10867
11-22 23:42:44.816  3257 29283 D MQSService: registerApplicationScoutThread pid = 16548, packageName = com.minocular.dcw
11-22 23:42:44.833 16548 16548 D nativeloader: Configuring classloader-namespace for other apk /system/framework/org.apache.http.legacy.jar. target_sdk_version=33, uses_libraries=ALL, library_path=/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/lib/arm64:/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.minocular.dcw
11-22 23:42:44.841 16548 16548 D nativeloader: Configuring classloader-namespace for other apk /data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/lib/arm64:/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk!/lib/arm64-v8a, permitted_path=/data:/mnt/expand:/data/user/0/com.minocular.dcw
11-22 23:42:44.849 16548 16548 V GraphicsEnvironment: ANGLE Developer option for 'com.minocular.dcw' set to: 'default'
11-22 23:42:44.853 16548 16548 I ForceDarkHelperStubImpl: initialize for com.minocular.dcw , ForceDarkOrigin
11-22 23:42:44.944 16548 16548 I FirebaseCrashlytics: Initializing Firebase Crashlytics 18.4.1 for com.minocular.dcw
11-22 23:42:44.962 16548 16572 W m.minocular.dc: ClassLoaderContext type mismatch. expected=PCL, found=DLC (PCL[] | DLC[];PCL[/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk*1897457440:/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk!classes2.dex*1712346227:/data/app/~~XVEKej-jv_JiJafUPrzfMg==/com.minocular.dcw-4YxHRz7uWaUDUCcu0409Pg==/base.apk!classes3.dex*1179966630]{PCL[/system/framework/org.apache.http.legacy.jar*126433618]})
11-22 23:42:45.046  1660  3158 D PackageManager: set app  component=com.minocular.dcw/androidx.work.impl.background.systemjob.SystemJobService enabled state: 1 from null,uid=10867,pid=16548
11-22 23:42:45.065 16548 16584 I FA      :   adb shell setprop debug.firebase.analytics.app com.minocular.dcw
11-22 23:42:45.349  1660  1739 D PackageManager: set app  component=com.minocular.dcw/androidx.work.impl.background.systemalarm.RescheduleReceiver enabled state: 1 from null,uid=10867,pid=16548
11-22 23:42:45.380  1660  4360 D PackageManager: set app  component=com.minocular.dcw/androidx.work.impl.background.systemalarm.RescheduleReceiver enabled state: 1 from null,uid=10867,pid=16548
11-22 23:42:45.632  1660  3146 D ConnectivityService: requestNetwork for uid/pid:10867/16548 activeRequest: null callbackRequest: 37695 [NetworkRequest [ REQUEST id=37696, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10867 RequestorUid: 10867 RequestorPkg: com.minocular.dcw UnderlyingNetworks: Null] ]] callback flags: 0 order: 2147483647
11-22 23:42:45.635  1660  1816 D WifiNetworkFactory: got request NetworkRequest [ REQUEST id=37696, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10867 RequestorUid: 10867 RequestorPkg: com.minocular.dcw UnderlyingNetworks: Null] ]
11-22 23:42:45.636  1660  1816 D UntrustedWifiNetworkFactory: got request NetworkRequest [ REQUEST id=37696, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10867 RequestorUid: 10867 RequestorPkg: com.minocular.dcw UnderlyingNetworks: Null] ]
11-22 23:42:45.636  1660  1816 D OemPaidWifiNetworkFactory: got request NetworkRequest [ REQUEST id=37696, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VCN_MANAGED Uid: 10867 RequestorUid: 10867 RequestorPkg: com.minocular.dcw UnderlyingNetworks: Null] ]

And after that i am getting this everytime i click on it

11-22 23:44:05.388  1660  3146 D PackageManager: set app  component=com.minocular.dcw/androidx.work.impl.background.systemalarm.RescheduleReceiver enabled state: 1 from null,uid=10867,pid=16548
11-22 23:44:05.414  1660  3146 D PackageManager: set app  component=com.minocular.dcw/androidx.work.impl.background.systemalarm.RescheduleReceiver enabled state: 1 from null,uid=10867,pid=16548
Rohit3523 commented 7 months ago

Got the following errors from crashlytics

Fatal Exception: java.lang.RuntimeException: Unable to instantiate receiver com.minocular.dcw.widget.CBAWidget: java.lang.ClassNotFoundException: Didn't find class "com.minocular.dcw.widget.CBAWidget" on path: DexPathList[[zip file "/data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/base.apk"],nativeLibraryDirectories=[/data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/lib/arm64, /data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4449)
       at android.app.ActivityThread.access$1800(ActivityThread.java:275)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:210)
       at android.os.Looper.loop(Looper.java:299)
       at android.app.ActivityThread.main(ActivityThread.java:8280)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
Caused by java.lang.ClassNotFoundException: Didn't find class "com.minocular.dcw.widget.CBAWidget" on path: DexPathList[[zip file "/data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/base.apk"],nativeLibraryDirectories=[/data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/lib/arm64, /data/app/~~WbqXITtys0Sz2ZZBdEwMNg==/com.minocular.dcw-o1gZC8ia-sAnCRHznzi-aw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
       at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
       at android.app.AppComponentFactory.instantiateReceiver(AppComponentFactory.java:110)
       at androidx.core.app.CoreComponentFactory.instantiateReceiver(CoreComponentFactory.java:60)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:4442)
       at android.app.ActivityThread.access$1800(ActivityThread.java:275)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2179)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:210)
       at android.os.Looper.loop(Looper.java:299)
       at android.app.ActivityThread.main(ActivityThread.java:8280)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
Rohit3523 commented 7 months ago

@sAleksovski Can you suggest me fix

sAleksovski commented 7 months ago

I think that the crashlytics error is from #50 . Other than that I don't see any error in the log.

Can you try reinstalling the app, restarting your phone, testing with a different phone?

Since it is working with the apk mentioned in the release section, it must be something specific to your app, but I don't know what it is.

sAleksovski commented 7 months ago

Do you have any update here? If it is still not working, can you create a minimal reproducible example that I can check?

sAleksovski commented 6 months ago

I'm closing this since there was no update in a while... I changed the timeout from 5 to 30 seconds for the tasks, in case that was your error (http call talking too long).

If you still have the problem, post a reproducible example that I can try.