android.app.application can not be cast to android.app.Activity

1,在做dialog 弹框提示的时候,报错了!

android.app.application can not be cast to android.app.Activity

看了一下代码,使用了全局的自定义的application类,但是没有在AndroidManifest.xml中添加该类的声明。也可以把application context 上下文替换成 activity的context文。

2,android.app.Application cannot be cast to myApplication

这个异常是因为在项目中添加了自定义的Application类,但是没有在AndroidManifest.xml中添加该类的声明,调用时编译器会抛出异常: java.lang.ClassCastException: android.app.Application cannot be cast to myApplication

< application

android:label=...

android:name=". myApplication类名">

相关推荐
q***718515 小时前
MySQL--》如何在MySQL中打造高效优化索引
android·mysql·adb
IT痴者17 小时前
《PerfettoSQL 的通用查询模板》---Android-trace
android·开发语言·python
游戏开发爱好者817 小时前
iOS IPA 上传工具全面解析,从 Transporter 到开心上架(Appuploader)命令行的高效上架实践
android·ios·小程序·https·uni-app·iphone·webview
alexhilton19 小时前
Jetpack Compose中的阴影艺术
android·kotlin·android jetpack
百***61871 天前
Spring的构造注入
android·java·spring
Tom4i1 天前
Kotlin 中的 inline 和 reified 关键字
android·开发语言·kotlin
yi诺千金1 天前
Android U 自由窗口(浮窗)——启动流程(system_server侧流程)
android
清空mega1 天前
第11章 网络编程
android·网络
自动化BUG制造器1 天前
Android UI 线程不一定是主线程
android
无知的前端1 天前
一文读懂-Jetpack与AndroidX
android·kotlin·android jetpack