Reputation: 330
I have few percent crashes when application from start points (launch activity, receivers) cannot be cast to my application.
My launch activity:
override fun onCreate(savedInstanceState: Bundle?) {
(application as MyApp)
...
}
My app extends MultiDexApplication:
public class MyApp extends MultiDexApplication {
...
Crash log:
Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.my.myapp.MyApp
at com.my.myapp.prelogin.presentation.LaunchActivity.onCreate(LaunchActivity.kt:59)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I spent a lot of time looking for this problem, but could not find a solution. I think it's trouble in android sdk.
p.s. I have name tag on manifest file
Upvotes: 3
Views: 2731
Reputation: 91
Do this in your Manifest file
<application
android:name="your.Packagename.CpuSpyApp"
Upvotes: 9