Android的Logcat命令详解:翻译Enabling logcat Logging

Android的Logcat命令详解

——翻译Enabling logcat Logging

田海立@优快云

2011/07/28

Android LOG系统提供了收集和查看系统调试输出的功能。各种应用程序和系统其他部分输出的LOG都存储在一些循环缓冲区里,这些缓冲区可以通过 logcat 命令来查看和过滤使用。

使用logcat命令

你可以用 logcat 命令来查看和控制系统LOG Buffer里内容,通常用法:

[adb] logcat [<option>] ... [<filter-spec>] ...

这节下面内容解释过滤以及命令的选项。关于选项的全面总结可参看:logcat命令选项列表

你可以在你的电脑,也可以通过运行在模拟器/设备上的远程adb shell端来使用logcat命令。在你的电脑上查看LOG输出:

$ adb logcat

通过远端 adb shell,可以这样:

# logcat

过滤Log输出

Android LOG信息都有一个标签(tag)和它的优先级(priority)。

· LOG的标签是一个简短的描述来指示发生在哪一个系统部件内,在写LOG时指定。(比如:“View”就是查看VIEW系统的标签).

· 优先级有下列几种,按照优先级从低到高顺序排列为:

o V— Verbose (最低优先级)

o D— Debug

o I— Info

o W— Warning

o E— Error

o F— Fatal

o S— Silent (最高优先级,没有任何输出)

在运行logcat的时候在前两列的信息中你就可以看到 logcat 的标签列表和优先级别,它是这样标出的<priority>/<tag>.

下面是一个logcat输出的例子,它的优先级就是“I”,标签是“ActivityManage”:

I/ActivityManager( 585): Starting activity: Intent { action=android.intent.action...}

为了让LOG输出达到可管理的级别,你还可以用过滤器来限制LOG输出,过滤器可以帮助只是显示你感兴趣的tag-priority组合的信息,而隐藏其他信息。

A过滤器语句按照tag:priority ...格式描述。这里,tag表示是感兴趣的标签,priority是表示报告指定标签的最低等级。 包含上面tag的信息或者指定优先级之上的信息被写入LOG。你可以在一个过滤表达式中提供多个tag:priority声明,这些声明之间用空白符间隔。

下面有一个过滤表达式的例子,例子表示不显示其他所有的LOG信息,除了那些标签为“ActivityManager”且优先级为“Info”以上的和标签为“ MyApp”且优先级为“ Debug”以上的信息。

adb logcat ActivityManager:I MyApp:D *:S

上面表达式的最后的元素*:S,,是设置所有标签的优先级为“silent”,这样保证只有“View”和“MyApp”的LOG才会显示。用*:S的是确保日志输出被限制在你明确指定的过滤表达式的极好方法——它使的你的过滤器在LOG输出时就像一个“白名单”。

下面过滤语句显示优先级为warning或更高的LOG日志信息:

adb logcat *:W

如果你在电脑上运行logcat(相比远程运行adb shell),你还可以通过为环境变量ANDROID_LOG_TAGS指定一个参数来设置缺省的过滤器:

export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S"

需要注意,如果你从远端运行logcat或者使用adb shell logcat,ANDROID_LOG_TAGS过滤器并不能应用在模拟器/设备实例上。

控制LOG输出格式

Log日志信息除了包括标签和优先级外,还有许多其他元数据域。可以修改日志的输出格式,来显示出特定的元数据域。可以通过-v选项来指定下列所支持的格式化输出。

· brief— 显示priority/tag和打印LOG进程的PID((缺省格式)。

· process— 仅仅显示PID。.

· tag— 仅仅显示priority/tag。

· thread— 显示进程:线程和priority/tag.

· raw— 显示原始LOG信息,不显示其他元数据域。

· time— 显示日期,发生时间,priority/tag和打印LOG进程的PID。

· long— 显示所有的元数据域和LOG信息,他们之间用空白行隔开。

当启动了logcat,你可以通过-v选项来指定输出格式:

[adb] logcat [-v <format>]

下面是用 thread输出格式来产生的LOG的例子:

adb logcat -v thread

要注意的是你只能用-v 选项来指定一个输出格式。

查看指定的LOG Buffer

Android日志系统有多个循环缓冲区,并不是所有的LOG信息都把LOG输出到默认循环缓冲区。为了看到其他缓冲区的LOG信息,你需要通过-b 选项来启动logcat。来看其他循环缓冲区。这些缓冲区有:

· radio— 查看与无线/电话相关的缓冲区里的信息。

· events— 查看和事件相关的的缓冲区。

· main— 查看main缓冲区里的LOG (缺省)

-b 选项使用方法:

[adb] logcat [-b <buffer>]

下面的例子演示怎么查看包含radio 和 telephony信息的LOG缓冲区:

adb logcat -b radio

查看stdout和stderr

在默认状态下,Android系统输出stdout和 stderr (System.out和System.err)到/dev/null。在运行Dalvik VM的进程中,有一个系统可以备份日志输出。在这种情况下,系统会用stdout和stderr和优先级 I.来记录日志信息。

通过这种方法来指定输出的路径,你可以停止运行的模拟器/设备,然后通过用命令setprop使输出重定向。

$ adb shell stop
$ adb shell setprop log.redirect-stdio true
$ adb shell start

系统在你关闭模拟器/设备前设置会一直保留这些设置。为了使这个设置作为你的模拟器/设备的默认设置,可以通过添加到设备的文件/data/local.prop中。

Logcat命令选项列表

选项

描述

-b<buffer>

加载一个指定的LOG Buffer供查看,比如event或radio。 默认值是main 。具体参考查看指定的Log Buffers.

-c

清除整个 log并退出。

-d

输出LOG到屏幕上并退出。

-f<filename>

写LOG信息到<filename>。默认是stdout.

-g

打印指定LOG Buffer的大小并退出。

-n<count>

设置日志的最大数目<count>,默认值是4,需要和选项-r一起使用。

-r<kbytes>

Rotates每输出<kbytes>写LOG文件,默认值为16,需要和选项-f一起使用。

-s

设置默认的过滤级别为silent。

-v<format>

Sets 设置LOG的输出格式,默认的是brief格式,要知道更多的支持的格式,参看控制LOG输出格式.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

附,大家看两张在WORD里编辑的效果:

一、开头



二、结尾


2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for user 0 2025-09-03 20:41:06.091 718-744 AppHibernationService system_server E Package com.example.myapplication is not installed for any user 2025-09-03 20:48:07.905 718-858 InputDispatcher system_server E channel 'e438984 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:48:23.392 718-858 InputDispatcher system_server E channel '3a68b4d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:49:55.365 718-858 InputDispatcher system_server E channel '5f148eb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:50:49.872 718-858 InputDispatcher system_server E channel 'c3204c4 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:51:07.596 718-858 InputDispatcher system_server E channel '32c4c88 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:51:29.776 718-858 InputDispatcher system_server E channel '26b31b2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:52:59.612 718-858 InputDispatcher system_server E channel '95aa8f8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 20:54:02.033 718-858 InputDispatcher system_server E channel '6a720b8 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:00:20.868 718-858 InputDispatcher system_server E channel '207de1e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-03 21:05:38.221 718-858 InputDispatcher system_server E channel 'c1f632b com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:44:52.229 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 .apps.wellbeing com.google.android.apps.wellbeing E Failed to open APK '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk': I/O error 2025-09-07 20:44:52.232 1830-1942 ResourcesManager com.google.android.apps.wellbeing E failed to add asset path '/data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk' java.io.IOException: Failed to load asset path /data/app/~~dJ88ZxVdANwbzdqaLfO8BA==/com.example.myapplication-Oci8KYGLbCHl-jUio4U6EQ==/base.apk at android.content.res.ApkAssets.nativeLoad(Native Method) at android.content.res.ApkAssets.<init>(ApkAssets.java:322) at android.content.res.ApkAssets.loadFromPath(ApkAssets.java:171) at android.app.ResourcesManager.loadApkAssets(ResourcesManager.java:618) at android.app.ResourcesManager$ApkAssetsSupplier.load(ResourcesManager.java:287) at android.app.ResourcesManager.createAssetManager(ResourcesManager.java:714) at android.app.ResourcesManager.createResourcesImpl(ResourcesManager.java:801) at android.app.ResourcesManager.findOrCreateResourcesImplForKeyLocked(ResourcesManager.java:854) at android.app.ResourcesManager.createResources(ResourcesManager.java:1199) at android.app.ResourcesManager.getResources(ResourcesManager.java:1301) at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:2979) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2154) at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:2140) at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:2481) at android.content.pm.PackageItemInfo.loadUnsafeLabel(PackageItemInfo.java:237) at android.content.pm.PackageItemInfo.loadLabel(PackageItemInfo.java:226) at android.app.ApplicationPackageManager.getApplicationLabel(ApplicationPackageManager.java:2526) at cut.c(PG:38) at cfv.apply(PG:391) at e$$ExternalSyntheticApiModelOutline1.m(D8$$SyntheticClass:47) at lcx.accept(PG:44) at j$.util.stream.M0.accept(SourceFile:3) at j$.util.D.x(SourceFile:24) at j$.util.T.forEachRemaining(SourceFile:24) at j$.util.stream.b.c(SourceFile:21) at j$.util.stream.b.y(SourceFile:8) at j$.util.stream.F.b(SourceFile:5) at j$.util.stream.b.f(SourceFile:35) at j$.util.stream.c1.collect(SourceFile:83) at bva.a(PG:99) at kbp.a(PG:301) at kbp.a(PG:38) at ltp.a(PG:3) at lsv.run(PG:19) at ltr.run(PG:5) at lrz.run(PG:17) at idd.run(PG:3) at loz.run(PG:50) at hsu.run(PG:768) at java.lang.Thread.run(Thread.java:1119) at ieo.run(PG:63) 2025-09-07 20:47:00.731 718-858 InputDispatcher system_server E channel 'd671972 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-07 20:52:16.888 718-858 InputDispatcher system_server E channel '54ceef5 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:19:19.039 718-858 InputDispatcher system_server E channel 'da9443c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:28:44.520 718-858 InputDispatcher system_server E channel 'fb3dc4e com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 08:31:15.953 718-858 InputDispatcher system_server E channel '50c58e2 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-10 09:08:31.738 718-1763 TransitionController system_server E Set visible without transition ActivityRecord{10540855 u0 com.example.myapplication/.MainActivity t25} playing=true caller=com.android.server.wm.TaskFragment.resumeTopActivity:1629 2025-09-10 09:46:26.507 718-858 InputDispatcher system_server E channel 'dc063cb com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 08:57:50.144 718-858 InputDispatcher system_server E channel '1f6629d com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:00:15.359 718-858 InputDispatcher system_server E channel 'b8ebe12 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:08:43.780 718-858 InputDispatcher system_server E channel 'b3a4af9 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:09:46.460 718-858 InputDispatcher system_server E channel 'e65939a com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:18.549 718-858 InputDispatcher system_server E channel '97c3cce com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:10:20.415 718-858 InputDispatcher system_server E channel '4a4890c com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:15:34.082 718-858 InputDispatcher system_server E channel '5112bb7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:20:13.015 718-858 InputDispatcher system_server E channel 'd3fcd81 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:21:45.786 718-858 InputDispatcher system_server E channel '83178b7 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-17 09:40:09.328 718-858 InputDispatcher system_server E channel 'b88d2d6 com.example.myapplication/com.example.myapplication.MainActivity' ~ Channel is unrecoverably broken and will be disposed! 2025-09-22 17:06:12.048 13959-13959 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:06:12.233 13959-13959 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:06:12.235 13959-13959 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:06:12.271 13959-13959 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:06:12.588 13959-13959 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/lib/x86_64:/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:06:12.595 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:06:12.607 13959-13959 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:06:12.608 13959-13959 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:06:12.678 13959-13993 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:06:12.683 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4d6f8) locale list changing from [] to [en-US] 2025-09-22 17:06:12.754 13959-13959 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:06:12.756 13959-13959 e.myapplication com.example.myapplication I AssetManager2(0x79d591a508f8) locale list changing from [] to [en-US] 2025-09-22 17:06:12.758 13959-13993 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:06:12.758 13959-13993 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:06:12.770 13959-13959 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:06:12.779 13959-13993 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:06:12.779 13959-13993 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:06:12.846 13959-13959 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:06:12.848 13959-13959 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:06:12.917 13959-13959 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:06:12.923 13959-13959 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:06:12.923 13959-13959 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:06:13.033 13959-13959 TransactionExecutor com.example.myapplication E Failed to execute the transaction: tId:-782804407 ClientTransaction{ tId:-782804407 transactionItems=[ tId:-782804407 LaunchActivityItem{activityToken=android.os.BinderProxy@be43358,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=184265485,info=ActivityInfo{a09354c com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.535 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@456b8d9,shareableActivityToken=android.os.BinderProxy@615029e,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:-782804407 ResumeActivityItem{mActivityToken=android.os.BinderProxy@be43358,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:-782804407 Target activity: com.example.myapplication.MainActivity tId:-782804407 ] tId:-782804407 } 2025-09-22 17:06:13.034 13959-13959 AndroidRuntime com.example.myapplication D Shutting down VM 2025-09-22 17:06:13.036 13959-13959 AndroidRuntime com.example.myapplication E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 13959 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:06:13.048 13959-13959 Process com.example.myapplication I Sending signal. PID: 13959 SIG: 9 2025-09-22 17:08:38.233 14080-14080 e.myapplication com.example.myapplication I Late-enabling -Xcheck:jni 2025-09-22 17:08:38.266 14080-14080 e.myapplication com.example.myapplication I Using CollectorTypeCMC GC. 2025-09-22 17:08:38.267 14080-14080 e.myapplication com.example.myapplication W Unexpected CPU variant for x86: x86_64. Known variants: atom, sandybridge, silvermont, goldmont, goldmont-plus, goldmont-without-sha-xsaves, tremont, kabylake, alderlake, default 2025-09-22 17:08:38.408 14080-14080 nativeloader com.example.myapplication D Load libframework-connectivity-tiramisu-jni.so using APEX ns com_android_tethering for caller /apex/com.android.tethering/javalib/framework-connectivity-t.jar: ok 2025-09-22 17:08:38.470 14080-14080 nativeloader com.example.myapplication D Load /data/user/0/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so using system ns (caller=<unknown>): ok 2025-09-22 17:08:38.464 14080-14080 re-initialized> com.example.myapplication W type=1400 audit(0.0:1899): avc: granted { execute } for path="/data/data/com.example.myapplication/code_cache/startup_agents/3fc68f17-agent.so" dev="dm-55" ino=361083 scontext=u:r:untrusted_app:s0:c217,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c217,c256,c512,c768 tclass=file app=com.example.myapplication 2025-09-22 17:08:38.484 14080-14080 e.myapplication com.example.myapplication W hiddenapi: DexFile /data/data/com.example.myapplication/code_cache/.studio/instruments-c9b0d10a.jar is in boot class path but is not in a known location 2025-09-22 17:08:38.644 14080-14080 e.myapplication com.example.myapplication W Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled. 2025-09-22 17:08:38.644 14080-14080 e.myapplication com.example.myapplication W Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled. 2025-09-22 17:08:38.824 14080-14080 nativeloader com.example.myapplication D Configuring clns-9 for other apk /data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk. target_sdk_version=36, uses_libraries=, library_path=/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/lib/x86_64:/data/app/~~YtxlO7izXbUn7DwQyfSn6g==/com.example.myapplication-WpLJzT4veBLnMmMJCcbkmw==/base.apk!/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication 2025-09-22 17:08:38.836 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4c758) locale list changing from [] to [en-US] 2025-09-22 17:08:38.838 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a46fd8) locale list changing from [] to [en-US] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V Currently set values for: 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_pkgs=[] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V angle_gl_driver_selection_values=[] 2025-09-22 17:08:38.843 14080-14080 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in per-application setting 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V ANGLE allowlist from config: com.dreamgames.royalmatch com.dts.freefiremax com.dxx.firenow com.gramgames.mergedragons com.ludo.king com.mojang.minecraftpe com.my.defense com.nintendo.zaka com.os.airforce com.playrix.fishdomdd.gplay io.teslatech.callbreak jp.konami.prospia net.peakgames.toonblast 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V com.example.myapplication is not listed in ANGLE allowlist or settings, returning default 2025-09-22 17:08:38.844 14080-14080 GraphicsEnvironment com.example.myapplication V Neither updatable production driver nor prerelease driver is supported. 2025-09-22 17:08:38.888 14080-14096 DisplayManager com.example.myapplication I Choreographer implicitly registered for the refresh rate. 2025-09-22 17:08:38.891 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a4d6f8) locale list changing from [] to [en-US] 2025-09-22 17:08:38.929 14080-14096 EGL_emulation com.example.myapplication I Opening libGLESv1_CM_emulation.so 2025-09-22 17:08:38.930 14080-14096 EGL_emulation com.example.myapplication I Opening libGLESv2_emulation.so 2025-09-22 17:08:38.959 14080-14096 HWUI com.example.myapplication W Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2025-09-22 17:08:38.960 14080-14096 HWUI com.example.myapplication W Failed to initialize 101010-2 format, error = EGL_SUCCESS 2025-09-22 17:08:38.966 14080-14080 AppCompatDelegate com.example.myapplication D Checking for metadata for AppLocalesMetadataHolderService : Service not found 2025-09-22 17:08:38.967 14080-14080 e.myapplication com.example.myapplication I AssetManager2(0x79d591a50c18) locale list changing from [] to [en-US] 2025-09-22 17:08:38.979 14080-14080 ashmem com.example.myapplication E Pinning is deprecated since Android Q. Please use trim or other methods. 2025-09-22 17:08:39.036 14080-14080 CompatChangeReporter com.example.myapplication D Compat change id reported: 377864165; UID 10217; state: ENABLED 2025-09-22 17:08:39.037 14080-14080 DesktopModeFlags com.example.myapplication D Toggle override initialized to: OVERRIDE_UNSET 2025-09-22 17:08:39.101 14080-14080 HWUI com.example.myapplication W Image decoding logging dropped! 2025-09-22 17:08:39.107 14080-14080 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:08:39.108 14080-14080 e.myapplication com.example.myapplication I hiddenapi: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (runtime_flags=0, domain=platform, api=unsupported) from Landroidx/appcompat/widget/ViewUtils; (domain=app) using reflection: allowed 2025-09-22 17:08:39.215 14080-14080 TransactionExecutor com.example.myapplication E Failed to execute the transaction: tId:1940201582 ClientTransaction{ tId:1940201582 transactionItems=[ tId:1940201582 LaunchActivityItem{activityToken=android.os.BinderProxy@7091517,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 xflg=0x4 cmp=com.example.myapplication/.MainActivity },ident=36553713,info=ActivityInfo{8c6a69b com.example.myapplication.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.536 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw411dp w411dp h914dp 420dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1080, 2400) mAppBounds=Rect(0, 0 - 1080, 2400) mMaxBounds=Rect(0, 0 - 1080, 2400) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.2 s.2 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@a09354c,shareableActivityToken=android.os.BinderProxy@8f10995,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1080, 2400), taskFragmentBounds=Rect(0, 0 - 1080, 2400)}} tId:1940201582 ResumeActivityItem{mActivityToken=android.os.BinderProxy@7091517,procState=-1,isForward=true,shouldSendCompatFakeFocus=false} tId:1940201582 Target activity: com.example.myapplication.MainActivity tId:1940201582 ] tId:1940201582 } 2025-09-22 17:08:39.215 14080-14080 AndroidRuntime com.example.myapplication D Shutting down VM 2025-09-22 17:08:39.218 14080-14080 AndroidRuntime com.example.myapplication E FATAL EXCEPTION: main Process: com.example.myapplication, PID: 14080 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222) at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133) at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loopOnce(Looper.java:248) at android.os.Looper.loop(Looper.java:338) at android.app.ActivityThread.main(ActivityThread.java:9067) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932) Caused by: java.lang.ClassCastException: androidx.appcompat.widget.AppCompatImageButton cannot be cast to android.widget.Button at com.example.myapplication.MainActivity.setButtonListeners(MainActivity.java:107) at com.example.myapplication.MainActivity.onCreate(MainActivity.java:28) at android.app.Activity.performCreate(Activity.java:9155) at android.app.Activity.performCreate(Activity.java:9133) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262) ... 13 more 2025-09-22 17:08:39.227 14080-14080 Process com.example.myapplication I Sending signal. PID: 14080 SIG: 9
最新发布
09-23
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值