OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

InnovacationTargetException #2146

Closed Asalerm closed 2 days ago

Asalerm commented 3 months ago

This the error I get when trying to .initwithContext().

jinliu9508 commented 3 months ago

Hello @Asalerm, could you provide more info like a stack trace, SDK version, build environment, and details on how you were calling .initWithContext()?

Asalerm commented 3 months ago

Hello @Asalerm, could you provide more info like a stack trace, SDK version, build environment, and details on how you were calling .initWithContext()?

I am using SDK version 5.0.0

Asalerm commented 3 months ago

@jinliu9508 and when I changed it to 5.1.8 my build crashes

jkasten2 commented 3 months ago

@Asalerm please try out the latest SDK, 5.1.17. If you continue to see this error please provide the full stack trace.

RK-AndroidDev commented 3 months ago

Here is the latest stack trace for InvocationTargetException

Fatal Exception: java.lang.reflect.InvocationTargetException: at java.lang.reflect.Constructor.newInstance0(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:88) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getAllServices(ServiceProvider.kt:55) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:71) at com.onesignal.common.services.ServiceProvider.getAllServices(ServiceProvider.kt:55) at com.onesignal.common.services.ServiceProvider.getAllServices$com_onesignal_core(ServiceProvider.kt:31) at com.onesignal.core.internal.startup.StartupService$scheduleStart$1.invokeSuspend(StartupService.kt:20) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Caused by java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() at android.os.Handler.(Handler.java:203) at android.os.Handler.(Handler.java:117) at android.app.Activity.(Activity.java:837) at com.onesignal.core.internal.permissions.impl.RequestPermissionService.(RequestPermissionService.kt:13) at java.lang.reflect.Constructor.newInstance0(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:88) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getServiceOrNull(ServiceProvider.kt:79) at com.onesignal.common.services.ServiceProvider.getService(ServiceProvider.kt:67) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:81) at com.onesignal.common.services.ServiceProvider.getAllServices(ServiceProvider.kt:55) at com.onesignal.common.services.ServiceRegistrationReflection.resolve(ServiceRegistration.kt:71) at com.onesignal.common.services.ServiceProvider.getAllServices(ServiceProvider.kt:55) at com.onesignal.common.services.ServiceProvider.getAllServices$com_onesignal_core(ServiceProvider.kt:31) at com.onesignal.core.internal.startup.StartupService$scheduleStart$1.invokeSuspend(StartupService.kt:20) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:458) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Asalerm commented 3 months ago

from jnius import autoclass

Accessing necessary Android classes

PythonActivity = autoclass('org.kivy.android.PythonActivity') OneSignal = autoclass('com.onesignal.OneSignal')

Get the current Android activity

activity = PythonActivity.mActivity

OneSignal.initWithContext(activity, "my_app_id")

OneSignal.setLogLevel(OneSignal.LOG_LEVEL.VERBOSE, OneSignal.LOG_LEVEL.NONE)

Request notification permissions (optional)

OneSignal.Notifications.requestPermission()

I am using version 5.1.8

The error i get: InnovacationTargetException.

jkasten2 commented 3 months ago

@RK-AndroidDev based on the stack trace it looks like you are running OneSignal-Android-SDK 5.1.16 which is know to have this bug. Please update to 5.1.17.

jkasten2 commented 3 months ago

@Asalerm could you please try updating to 5.1.17?

Could you provide the full stack trace of the crash?

jinliu9508 commented 2 days ago

Closing this issue as it has been resolved in the latest SDK version, and there are no further updates. If anyone is still experiencing this issue, please try upgrading to the latest SDK and open a new issue if the problem persists after upgrading.