且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"无法找到本机库"在本地活动的应用程序错误

更新时间:2023-01-18 22:27:21

您将需要阅读的logcat输出,看看前大跌,其中$ P $发生加载pvented本机库。我使用阿克拉我的应用程序(生成包含logcat的输出崩溃报告),但作为一个快速的解决方案,以获得没有实现一个整体的崩溃报告系统的logcat输出,你可以使用这样的事情在一个测试版本,并让用户运行它:

You will need to read the logcat output to see what happened prior to the crash, which prevented the native library from loading. I use Acra for my apps (generates crash reports containing logcat output), but as a quick solution to get the logcat output without implementing a whole crash reporting system, you could use something like this in a test build, and have the user run it:

try
{
    Process process = Runtime.getRuntime().exec( "logcat -d" );
    BufferedReader bufferedReader = new BufferedReader(
        new InputStreamReader( process.getInputStream() ) );
    StringBuilder log = new StringBuilder();
    String line = "";
    while( ( line = bufferedReader.readLine() ) != null ) {
        log.append( line );
    }
    // Output available via log.toString().. do whatever with it
} 
catch( IOException e ) {}

如果你看一下来源$ C ​​$下NativeActivty ,这个异常你看到被扔在OnCreate()方法(参见线171),所以如果你重写该方法在派生类中NativeActivity的的,你可以抓住它,抓住的logcat输出那里。然后,你可以将日志保存到一个文件中,有一个用户使用受影响设备运行测试和文件通过电子邮件发送给你,例如。

If you look at the source code for NativeActivty, this exception you are seeing gets thrown in the onCreate() method (see line 171), so if you override that method in a derived class of NativeActivity, you can catch it and grab the logcat output from there. Then you could save the log to a file and have a user with an affected device run the test and email the file to you, for example.

有关覆盖的另一个好处的onCreate(),是不是也让你重现一些什么样的推移幕后,更多的调试日志记录,以帮助你追踪问题。

Another good thing about overriding onCreate(), is it will also allow you to reproduce some of what goes on behind the scenes, with more debug logging to help you track down the problem.