我是Android SDK/API环境的新手。这是我第一次试着画一个图表。我尝试在模拟器上使用3个不同的免费库运行不同种类的示例代码,没有显示在布局屏幕上。日志猫正在重复如下信息:

 W/Trace(1378): Unexpected value from nativeGetEnabledTags: 0
 I/Choreographer(1378): Skipped 55 frames!  The application may be doing too much work on its main thread. 

当我运行一个与授权库的评估副本相关的示例代码时,这个问题并没有持续存在,图表也正常工作。


当前回答

this usually happens when you are executing huge processes in main thread. it's OK to skip frames less than 200. but if you have more than 200 skipped frames, it can slow down your application UI thread. what you can do is to do these processes in a new thread called worker thread and after that, when you want to access and do something with UI thread(ex: do something with views, findView etc...) you can use handler or runOnUiThread(I like this more) in order to display the processing results. this absolutely solves the problem. using worker threads are very useful or even must be used when it comes to this cases.

https://stacklearn.ir

其他回答

优化你的图片…不要使用大于100KB的图片…图像加载占用太多CPU,导致你的应用程序挂起。

我也有同样的问题。当我在另一台计算机上运行这段代码时,它工作得很好。然而,在我的系统上,它显示“应用程序可能在主线程上做了太多的工作”。

我通过重新启动Android工作室解决了我的问题[文件->无效缓存/重新启动->单击“无效并重新启动”]。

我在开发一个在网格布局上使用大量可绘制png文件的应用程序时遇到了同样的问题。我也尽量优化我的代码。但这对我来说行不通。然后我尝试减小这些png的大小。我猜它工作得绝对很好。所以我的建议是减少可绘制资源的大小。

我也有同样的问题。Android模拟器在Android < 6.0上运行良好。当我使用模拟器Nexus 5 (Android 6.0)时,应用程序在I/Choreographer:在日志中跳过帧时运行非常慢。

所以,我解决了这个问题,在Manifest文件hardwareAccelerated选项更改为true,像这样:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application android:hardwareAccelerated="true">
        ...
    </application>
</manifest>

2022年1月更新。根据@M的评论。Ed:如果您的目标api为>= 14,则默认启用硬件加速。

正如上面其他人回答的那样,“跳过55帧!”意味着应用程序中有一些繁重的处理。

对于我的情况,我的申请过程并不繁琐。我反复检查了所有内容,并删除了那些我认为有点沉重的过程。

我删除了片段、活动、库,直到只剩下骨架。但是问题仍然没有消失。我决定检查一下资源,发现我使用的一些图标和背景相当大,因为我忘记检查这些资源的大小。

因此,我的建议是,如果以上答案都没有帮助,您也可以检查您的资源文件大小。