简体   繁体   English

打开跟踪文件时出错:没有这样的文件或目录(2)

[英]error opening trace file: No such file or directory (2)

I am getting the above error: 我收到上述错误:

error opening trace file: No such file or directory (2) 打开跟踪文件时出错:没有这样的文件或目录(2)

when I run my android application on the emulator. 当我在模拟器上运行我的android应用程序时。 Can someone tell me what could be the possible reason for this? 有人可以告诉我这可能是什么原因吗?

I am using android-sdk-20 and below lines are added to AndroidManifest.xml 我正在使用android-sdk-20,以下行添加到AndroidManifest.xml

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" />

I have also added the line: 我还添加了以下行:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

since I thought that there may be some issue with writing to the sd card. 因为我认为写入SD卡可能存在一些问题。

It happens because you have not installed the minSdkVersion or targetSdkVersion in you're computer. 发生这种情况是因为您没有在计算机中安装minSdkVersion或targetSdkVersion。 I've tested it right now. 我已经测试过了

For example, if you have those lines in your Manifest.xml: 例如,如果您的Manifest.xml中包含这些行:

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />

And you have installed only the API17 in your computer, it will report you an error. 并且您仅在计算机中安装了API17,它将报告一个错误。 If you want to test it, try installing the other API version (in this case, API 8). 如果要测试它,请尝试安装其他API版本(在本例中为API 8)。

Even so, it's not an important error. 即使这样,这也不是一个重要的错误。 It doesn't mean that your app is wrong. 这并不意味着您的应用程序是错误的。

Sorry about my expression. 对不起,我的表情。 English is not my language. 英语不是我的语言。 Bye! 再见!

I think this is the problem 我认为这是问题所在

A little background 一点背景

Traceview is a graphical viewer for execution logs that you create by using the Debug class to log tracing information in your code. Traceview是用于查看执行日志的图形查看器,您可以使用Debug类在代码中记录跟踪信息。 Traceview can help you debug your application and profile its performance. Traceview可以帮助您调试应用程序并分析其性能。 Enabling it creates a .trace file in the sdcard root folder which can then be extracted by ADB and processed by traceview bat file for processing. 启用它会在sdcard根文件夹中创建一个.trace文件,然后可以由ADB提取该文件并由traceview bat文件进行处理以进行处理。 It also can get added by the DDMS. DDMS也可以添加它。

It is a system used internally by the logger. 它是记录器内部使用的系统。 In general unless you are using traceview to extract the trace file this error shouldnt bother you. 通常,除非您使用traceview提取跟踪文件,否则此错误不会困扰您。 You should look at error/logs directly related to your application 您应该查看与您的应用程序直接相关的错误/日志

How do I enable it: 如何启用它:

There are two ways to generate trace logs: 有两种方法可以生成跟踪日志:

  1. Include the Debug class in your code and call its methods such as startMethodTracing() and stopMethodTracing() , to start and stop logging of trace information to disk. 在代码中包含Debug类,并调用其方法,例如startMethodTracing()stopMethodTracing() ,以开始和停止将跟踪信息记录到磁盘。 This option is very precise because you can specify exactly where to start and stop logging trace data in your code. 此选项非常精确,因为您可以精确指定在代码中开始和停止记录跟踪数据的位置。

  2. Use the method profiling feature of DDMS to generate trace logs. 使用DDMS的方法概要分析功能来生成跟踪日志。 This option is less precise because you do not modify code, but rather specify when to start and stop logging with DDMS. 此选项不太精确,因为您不修改代码,而是指定何时启动和停止使用DDMS的日志记录。 Although you have less control on exactly where logging starts and stops, this option is useful if you don't have access to the application's code, or if you do not need precise log timing. 尽管您对开始和停止日志的确切位置的控制较少,但是如果您无权访问应用程序的代码或不需要精确的日志时间,则此选项很有用。

But the following restrictions exist for the above 但是上述存在以下限制

If you are using the Debug class, your application must have permission to write to external storage ( WRITE_EXTERNAL_STORAGE ). 如果使用的是Debug类,则您的应用程序必须具有写入外部存储( WRITE_EXTERNAL_STORAGE )的权限。

If you are using DDMS: Android 2.1 and earlier devices must have an SD card present and your application must have permission to write to the SD card. 如果您使用的是DDMS,则Android 2.1和更早版本的设备必须装有SD卡,并且您的应用程序必须具有写入SD卡的权限。 Android 2.2 and later devices do not need an SD card. Android 2.2及更高版本的设备不需要SD卡。 The trace log files are streamed directly to your development machine. 跟踪日志文件直接流式传输到您的开发计算机。

So in essence the traceFile access requires two things 所以本质上,traceFile访问需要两件事

1.) Permission to write a trace log file ie WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE for good measure 1.)允许写跟踪日志文件,即WRITE_EXTERNAL_STORAGEREAD_EXTERNAL_STORAGE

2.) An emulator with an SDCard attached with sufficient space. 2.)仿真器,其SD卡具有足够的空间。 The doc doesnt say if this is only for DDMS but also for debug, so I am assuming this is also true for debugging via the application. 该文档没有说明这是否仅适用于DDMS,还适用于调试,因此我假设这对于通过应用程序进行调试也是正确的。

What do I do with this error: 如何处理此错误:

Now the error is essentially a fall out of either not having the sdcard path to create a tracefile or not having permission to access it. 现在,错误实质上是由于没有sdcard路径来创建跟踪文件或没有访问权限而导致的。 This is an old thread, but the dev behind the bounty, check if are meeting the two prerequisites. 这是一个旧线程,但是赏金背后的开发人员请检查是否满足两个先决条件。 You can then go search for the .trace file in the sdcard folder in your emulator. 然后,您可以在模拟器的sdcard文件夹中搜索.trace文件。 If it exists it shouldn't be giving you this problem, if it doesnt try creating it by adding the startMethodTracing to your app. 如果存在,则不应该给您这个问题,如果它不尝试通过将startMethodTracing添加到您的应用程序来创建它。
I'm not sure why it automatically looks for this file when the logger kicks in. I think when an error/log event occurs , the logger internally tries to write to trace file and does not find it, in which case it throws the error.Having scoured through the docs, I don't find too many references to why this is automatically on. 我不确定为什么在启动记录器时它会自动查找该文件。我认为,当发生错误/日志事件时,记录器会在内部尝试写入跟踪文件而未找到它,在这种情况下它将引发错误。在文档中进行搜索后,我找不到太多关于为什么自动打开它的参考。 But in general this doesn't affect you directly, you should check direct application logs/errors. 但这通常不会直接影响您,您应该检查直接的应用程序日志/错误。 Also as an aside Android 2.2 and later devices do not need an SD card for DDMS trace logging. 另外,Android 2.2及更高版本的设备不需要SD卡即可记录DDMS跟踪信息。 The trace log files are streamed directly to your development machine. 跟踪日志文件直接流式传输到您的开发计算机。

Additional information on Traceview: 有关Traceview的其他信息:

Copying Trace Files to a Host Machine 将跟踪文件复制到主机

After your application has run and the system has created your trace files .trace on a device or emulator, you must copy those files to your development computer. 运行应用程序并且系统在设备或仿真器上创建跟踪文件.trace之后,必须将这些文件复制到开发计算机上。 You can use adb pull to copy the files. 您可以使用adb pull复制文件。 Here's an example that shows how to copy an example file, calc.trace, from the default location on the emulator to the /tmp directory on the emulator host machine: 这是一个示例,显示了如何将示例文件calc.trace从仿真器的默认位置复制到仿真器主机上的/ tmp目录:

adb pull /sdcard/calc.trace /tmp Viewing Trace Files in Traceview To run Traceview and view the trace files, enter traceview . adb pull /sdcard/calc.trace / tmp在Traceview中查看跟踪文件要运行Traceview并查看跟踪文件,请输入traceview。 For example, to run Traceview on the example files copied in the previous section, use: 例如,要对上一节中复制的示例文件运行Traceview,请使用:

traceview /tmp/calc Note: If you are trying to view the trace logs of an application that is built with ProGuard enabled (release mode build), some method and member names might be obfuscated. traceview / tmp / calc注意:如果尝试查看启用了ProGuard(发布模式构建)的应用程序的跟踪日志,可能会混淆某些方法和成员名称。 You can use the Proguard mapping.txt file to figure out the original unobfuscated names. 您可以使用Proguard mapping.txt文件来找出原始的原始名称。 For more information on this file, see the Proguard documentation. 有关此文件的更多信息,请参见Proguard文档。

I think any other answer regarding positioning of oncreate statements or removing uses-sdk are not related, but this is Android and I could be wrong. 我认为有关oncreate语句的位置或删除uses-sdk其他任何答案都没有关系,但这是Android,我可能是错的。 Would be useful to redirect this question to an android engineer or post it as a bug 将这个问题重定向到android工程师或将其发布为bug很有用

More in the docs 文档中的更多内容

Try removing the uses-sdk part form AndroidManifest.xml file. 尝试从AndroidManifest.xml文件中删除uses-sdk部分。 it worked for me! 它对我有用!

Don't use the Android Virtual Device with too low configuration. 不要使用配置过低的Android虚拟设备。 Let it be medium. 让它成为中等。

Write all your code below this 2 lines:- 在这两行下面编写所有代码:-

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

It worked for me without re-installing again. 它为我工作,而无需重新安装。

I didn't want to reinstall everything because I have so many SDK versions installed and my development environment is set up just right. 我不想重新安装所有内容,因为我安装了许多SDK版本,并且我的开发环境设置正确。 Getting it set up again takes way too long. 重新设置它需要太长时间。

What worked for me was deleting, then re-creating the Android Virtual Device, being certain to put in a value for SD Card Size (I used 200 MiB). 对我有用的是删除,然后重新创建Android虚拟设备,确定要输入SD卡大小值(我使用了200 MiB)。

AVD创建屏幕的屏幕截图

Additional information: 附加信息:

while the above does fix the problem temporarily, it is recurring. 尽管上述方法确实可以暂时解决问题,但这种情况仍在发生。 I just tried my application within Android Studio and saw this in the output log which I did not notice before in Eclipse: 我刚刚在Android Studio中试用了我的应用程序,并在输出日志中看到了这一点,之前我在Eclipse中没有注意到:

"/Applications/Android Studio.app/sdk/tools/emulator" -avd AVD_for_Nexus_S_by_Google -netspeed full -netdelay none

WARNING: Data partition already in use. Changes will not persist!
WARNING: SD Card image already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/sdcard.img
ko:Snapshot storage already in use: /Users/[user]/.android/avd/AVD_for_Nexus_S_by_Google.avd/snapshots.img

I suspect that changes to the log are not saving to the SD Card, so when LogCat tries to access the logs, they aren't there, causing the error message. 我怀疑对日志所做的更改没有保存到SD卡中,因此LogCat尝试访问日志时,它们不存在,从而导致错误消息。 The act of deleting the AVD and re-creating it removes the files, and the next launch is a fresh launch, allowing LogCat to access the virtual SD Card. 删除AVD并重新创建它的操作将删除文件,并且下一次启动是全新启动,从而使LogCat可以访问虚拟SD卡。

You will not have access to your real sd card in emulator. 您将无法在模拟器中访问您的真实SD卡。 You will have to follow the steps in this tutorial to direct your emulator to a directory on your development environment acting as your SD card. 您将必须按照本教程中的步骤将仿真器定向到开发环境中充当SD卡的目录。

Actually, the problem is that either /sys/kernel/debug is not mounted, or that the running kernel has no ftrace tracers compiled in so that /sys/kernel/debug/tracing is unavailable. 实际上,问题是未安装/sys/kernel/debug ,或者正在运行的内核没有编译ftrace跟踪程序,因此/sys/kernel/debug/tracing不可用。 This is the code throwing the error ( platform_frameworks_native/libs/utils/Trace.cpp ): 这是platform_frameworks_native/libs/utils/Trace.cpp错误的代码( platform_frameworks_native/libs/utils/Trace.cpp ):

void Tracer::init() {
    Mutex::Autolock lock(sMutex);

    if (!sIsReady) {
        add_sysprop_change_callback(changeCallback, 0);

        const char* const traceFileName =
                "/sys/kernel/debug/tracing/trace_marker";
        sTraceFD = open(traceFileName, O_WRONLY);
        if (sTraceFD == -1) {
            ALOGE("error opening trace file: %s (%d)", strerror(errno), errno);
            sEnabledTags = 0;   // no tracing can occur
        } else {
            loadSystemProperty();
        }

        android_atomic_release_store(1, &sIsReady);
    }
}

The log message could definitely be a bit more informative. 日志消息肯定可以提供更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打开跟踪文件时出错:没有这样的文件或目录(2),解决方案? - error opening trace file: No such file or directory (2), Solution? 打开跟踪文件时出错。 没有这样的文件或目录[2] - Error opening trace file. No such file or directory [2] Android - 错误打开跟踪文件:没有这样的文件或目录 - Android - error opening trace file: No such file or directory HttpURLConnection打开跟踪文件时出错:没有这样的文件或目录 - HttpURLConnection Error opening trace file: no such file or directory E / Trace:错误打开跟踪文件:没有这样的文件或目录(2) - E/Trace﹕ error opening trace file: No such file or directory (2) Android E / Trace(627):打开跟踪文件时出错:没有这样的文件或目录(2) - Android E/Trace(627): error opening trace file: No such file or directory (2) e / trace:打开跟踪文件时出错:没有这样的文件或目录(2) - e/trace : error opening trace file: No such file or directory (2) Android运行时错误:打开跟踪文件时出错:没有这样的文件或目录(2) - Android runtime error: error opening trace file: No such file or directory (2) LogCat错误打开跟踪文件时出错:没有这样的文件或目录 - LogCat error Error opening trace file: no such file or directory LogCat上的永久错误:“打开跟踪文件时出错:没有这样的文件或目录(2)” - Persistent error on LogCat: “Error opening trace file: No such file or directory (2)”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM