Original address: http://www.cnblogs.com/linguanh/(slide to the end of the article, directly see the solution)
Cause of the problem:
The first 5 days, because the project has a similar video recording function, first on the internet to find an open source project: Https://github.com/qdrzwd/VideoRecorder, download down, in debug non-confusing mode test several times, think the effect is good, It was developed on the basis of two times.
in the evening to integrate the project, prepare for the first confusion packaging (release mode), and then the first Test, the results, I expected the things happened, yes, is the confusion often occurs after the various jumps, for this kind of problem, do not blow not black, my experience is rich, is generally in Proguard-rules file (Android Studio) under the confusion set to solve, but I have to admit that this is the most difficult I have so far, until 15:46 formally resolved, how to say all 4 days, Baidu has no direct solution information, choose the text to sue.
Pre-order:
Let's talk about the background of this open source project, which is based on the background of Vine , Vine is a foreign company that makes short video-sharing, and is the name of their APP, after being acquired by Twitter, currently on-line video recording is based on the Android Mediarecorder class, but this class is more chicken, the truth, the use is not very big, used to practice or can be. Vine recorded video using JAVACV's own API, recording sounds using Android Audiorecord, as well, this open source project is based on the development of both. Here by the way, with the library, and the micro-vision, using the FFmpeg Library of their own compilation , vine using the JAVACV library. See here, you are not thinking, how do I know? In fact, it is very simple, to download these apps on the Internet, anti-compilation, look at Libs under the. So to know.
After checking the data online, JAVACV has provided video recording function, and it includes video editing and other image processing functions. An open source project link in JAVACV can download it: https://code.google.com/p/javacv/
Specific questions:
Well, the front blowing so much, first of all, I met the wonderful problem first.
From the bottom up, the last hint is to load the dynamic link library libjnipointer.so problem, this is a more important information, and two are javacpp.loader.loadLibrary , Nativelibrarydirectories=[/data/app/cn.itguy.recordvideodemo-1/lib/arm,/vendor/lib,/system/lib]] , they told me three O ', This problem is loaded Linux under the dynamic library failure, can not find, by the jar package inside the loader class LoadLibrary function triggered, the final location is not found in the mobile system of the Lib library, system, vendor.
Is there a kind of want to go to mobile phone system/lib inside to see jnipointer.so impulse? The fact is not to see, I said in the debug is not a problem, also proved that the library must exist, can not find is because of confusion.
The usual practice:
Because this kind of problem is not found in the library, generally we go back to the inside of our project . So folder looking for Wood has, this is a blind approach, first of all should look at the error message, such as above, the path can not find the system/lib is not related to the local project folder, the fact is, Libjnipointer.so this east, the original project inside is No.
Then it is confusing configuration file--proguard-rules: Specific all operations, the Internet has a very detailed example, I do not talk nonsense, directly to the situation I encountered surgery
First of all to open the jar package in order to ensure that the package is not mixed, we will use-keep and-dontwarn, and then make up a sentence not to confuse the native method->,, dependency injection does not confuse-> ;, see here, we will think, should do, generally is the line, may have comrades will point out to protect under. So ah,-libraryjars libs/xxx.so like this, actually do not,. So the default is not confused, all the above practices, generally speaking, is line , However, for this video recording, not yet.
Real Solution :
In the implementation of the above settings, if not yet, basically again Baidu is no use, because there is no Baidu above, and so I finished this article estimated to have.
Back to the root of the problem, it is loaded by the jar package inside the loader class LoadLibrary function trigger, the final location is not found in the mobile phone system Lib Library, system, vendor under the jnipointer.so, we how to do ah? Look at the source, or to do so, below I posted my search path, all the code is this video recording open source projects, javacpp inside:
First, log tracking to->, in New Avpacket () throws an exception, we point to-> because allocate () has no other action, we can skip it, find the static block in this class, it executes the->->-before the constructor >->, see LoadLibrary finally GetRuntime, the whole clue corresponding to the exception information, here, here is the system class, when the Libname = "Libjnipointer" When the time, can not find. presumably , some of the resources of the system were confused. There is a sentence in our obfuscation configuration :-keepattributes protects the given optional attribute, so we can use it to protect the project's annotations, resource files, resource directory names, inner classes, and so on, for example:, as it turns out, when I add to innerclasses , the problem is solved.
Workaround:
add in the obfuscation file Protect comments, resource files, resource directory names, internal classes (primary solutions) for projects
Android video recording obfuscation packaging native layer exception resolution