当前位置: 首页 > 知识库问答 >
问题:

尝试加载System.LoadLibrary(“Loader-JNI”)时应用程序崩溃

商松
2023-03-14
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.forsale.forsale-2/base.apk"],nativeLibraryDirectories=[/data/app/com.forsale.forsale-2/lib/arm64, /data/app/com.forsale.forsale-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libloader-jni.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:972)
        at java.lang.System.loadLibrary(System.java:1567)
        at com.netcompss.loader.LoadJNI.<clinit>(LoadJNI.java:15)
        at com.forsale.app.utils.facades.VideoCompressor$getCompressedVideo$retValue$1.invokeSuspend(VideoCompressor.kt:21)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
        at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:236)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:742)
fun getCompressVideo (video: String) {

        launch (Dispatchers.Main){
            viewModel.mediaViewModel.video = videoCompressor.getCompressedVideo(context, Uri.parse(viewModel.mediaViewModel.video))
        }
    }

override suspend fun getCompressedVideo(context: Context?, video: Uri): String {

            val retValue = withContext(Dispatchers.IO) {

                val inputFile = video.path
                Log.i("AMIRA3000" , inputFile)
                val loadJNI = LoadJNI()

                val workFolder: String = context!!.filesDir.absolutePath

                val outputFile: String = getFileFullName(
                    FilesConstants.VIDEO_FOLDER,
                    String.format(FilesConstants.VIDEO_NAME_FILE_FORMAT, System.currentTimeMillis())
                )

                val complexCommand = arrayOf(
                    "ffmpeg", "-y", "-i", inputFile, "-strict", "experimental", "-s", "320x240", "-r", "25", "-aspect", "4:3", "-ab", "48000", "-ac", "2", "-vcodec", "mpeg4", "-movflags", "+faststart", "-ar", "22050", "-b", "2097k", outputFile
                )

                loadJNI.run(complexCommand, workFolder, context)
            }

            return retValue.toString()
    }
public final class LoadJNI {

    static {
        System.loadLibrary("loader-jni");
    }

    /**
     * 
     * @param args ffmpeg command
     * @param workFolder working directory 
     * @param ctx Android context
     * @param isValidate apply validation to the command
     * @throws CommandValidationException
     */
    public void run(String[] args, String workFolder, Context ctx, boolean isValidate) throws CommandValidationException {
        Log.i(Prefs.TAG, "running ffmpeg4android_lib: " + Prefs.version);
        // delete previous log: this is essential for correct progress calculation
        String vkLogPath = workFolder + "vk.log";
        GeneralUtils.deleteFileUtil(vkLogPath);
        GeneralUtils.printCommand(args);

        //printInternalDirStructure(ctx);

        if (isValidate) {
            if (GeneralUtils.isValidCommand(args))
                load(args, workFolder, getVideokitLibPath(ctx), true);
            else
                throw new CommandValidationException();
        }
        else {
            load(args, workFolder, getVideokitLibPath(ctx), true);
        }

    }

    /**
     * 
     * @param args ffmpeg command
     * @param videokitSdcardPath working directory 
     * @param ctx Android context
     * @throws CommandValidationException
     */
    public void run(String[] args, String workFolder, Context ctx) throws CommandValidationException {
        run(args, workFolder, ctx, true);
    }


    private static void printInternalDirStructure(Context ctx) {
        Log.d(Prefs.TAG, "=printInternalDirStructure=");
        Log.d(Prefs.TAG, "==============================");
        File file = new File(ctx.getFilesDir().getParent());
        analyzeDir(file);
        Log.d(Prefs.TAG, "==============================");
    }

    private static void analyzeDir(File path) {
        if (path.isDirectory()) {
            Log.d(Prefs.TAG,"Scanning dir: " + path.getAbsolutePath());
            File[] files1 = path.listFiles();
            for (int i = 0; i < files1.length; i++) {
                analyzeDir(files1[i]);
            }
            Log.d(Prefs.TAG, "==========");
        }
        else {
            Log.d(Prefs.TAG, path.getAbsolutePath());

        }
    }

    private static String getVideokitLibPath(Context ctx) {

        //File file = new File(ctx.getFilesDir().getParent() + "/lib/");
        //analyzeDir(file);

        String videokitLibPath = ctx.getFilesDir().getParent()  + "/lib/libvideokit.so";

        File file = new File(videokitLibPath);
        if(file.exists())  {     
          Log.i(Prefs.TAG, "videokitLibPath exits: " + videokitLibPath);
        }
        else {
            Log.w(Prefs.TAG, "videokitLibPath not exits: " + videokitLibPath);
            videokitLibPath = ctx.getFilesDir().getParent()  + "/lib/arm64/libvideokit.so";
            Log.i(Prefs.TAG, "trying videokitLibPath: " + videokitLibPath);
            file = new File(videokitLibPath);
            if(file.exists())  {
                Log.i(Prefs.TAG, "videokitLibPath exits: " + videokitLibPath);
            }
            else {
                Log.w(Prefs.TAG, "videokitLibPath not exits: " + videokitLibPath);
                videokitLibPath = "/data/app/com.examples.ffmpeg4android_demo-1/lib/arm64/libvideokit.so";
                Log.i(Prefs.TAG, "trying videokitLibPath: " + videokitLibPath);
                file = new File(videokitLibPath);
                if(file.exists())  {
                    Log.i(Prefs.TAG, "videokitLibPath exits: " + videokitLibPath);
                }
                else {
                    Log.w(Prefs.TAG, "videokitLibPath not exits: " + videokitLibPath);
                    videokitLibPath = "/data/app/com.examples.ffmpeg4android_demo-2/lib/arm64/libvideokit.so";
                    Log.i(Prefs.TAG, "trying videokitLibPath: " + videokitLibPath);
                    if(file.exists())  {
                        Log.i(Prefs.TAG, "videokitLibPath exits: " + videokitLibPath);
                    }
                    else {
                        Log.e(Prefs.TAG, "can't find path of lib");
                    }
                }
            }
        }





        //String videokitLibPath = ctx.getFilesDir().getParent()  + "/lib/arm64/libvideokit.so";

        // only this works on Android M, and the number changes (demo-2, demo-1)
        //String videokitLibPath = "/data/app/com.examples.ffmpeg4android_demo-1/lib/arm64/libvideokit.so";


        Log.i(Prefs.TAG, "videokitLibPath: " + videokitLibPath);
        return videokitLibPath;

    }



    public void fExit( Context ctx) {
        fexit(getVideokitLibPath(ctx));
    }

    public native String fexit(String videokitLibPath);

    public native String unload();

    public native String load(String[] args, String videokitSdcardPath, String videokitLibPath, boolean isComplex);
}

暂时还没有答案

 类似资料:
  • 当我尝试连接Android Studio调试器时,我的一些应用程序崩溃,然后我收到以下错误: 我试着重启Windows 我正在使用最新版本的Android SDK,构建工具,。。。 此崩溃后的部分日志:

  • 主要活动 碎片 这是一个简单对话框的代码。 这里有一个我从中学习的链接。如果我只需通过调用按钮创建对话框,它就可以完全正常工作。

  • 我已经编译了一个用于jni的测试dll。除了#include之外,它实际上完全是空的 这是加载库的类: true是最后打印的内容,证明错误在true和loaded!之间!。如果我在eclipse中运行,会打印两条错误消息,但互联网不知道它们是什么。 信息: 堆栈转储是无信息的。 当我在维基百科页面上运行示例时,实验也失败了。它以同样的方式失败。

  • 当我运行应用程序时,它工作得很好,但是当我想调试一个变量值时,应用程序就崩溃了。下面是完整的调试日志。我不知道是什么错误来纠正它。你们能帮帮我吗?我读到了一些关于并且我禁用和启用了ADB集成,但没有帮助我。我试图清洁,重建和运行的项目再次和没有帮助我。每次我尝试开始调试时,应用程序都会崩溃。 提前谢谢!!

  • 我正在开发一个Android应用程序,它必须从文件中解析文本。 我的解析器中有以下方法。java类: 每当调用缓冲区时,我都会遇到问题。while循环中的readLine()方法。 我传递以下路径信息File对象是: 现在我已经看了堆栈和在线上的许多帖子,以便尝试解决这个问题,并尝试使用一些解决方案,但没有运气。这是我从错误堆栈跟踪中获得的一个片段。 我确信文件的路径是正确的,因为我在调试时检查了

  • 我尝试在1个应用程序中构建扫描仪和生成器。当我按下发电机按钮时,它突然崩溃了。我的日志中没有任何错误或警告。 这是我的生成器代码: 主活动代码: 有人知道怎么解决这个问题吗?请帮帮我。 更新 以下是我的生成器xml代码: 我希望这将有助于我的问题:( 更新:这是由我愚蠢的打字错误修正;)。非常感谢迄今为止所有回答我问题的人。我说不出我有多感激。特别是对于那个我已经投票支持正确答案的家伙。你真是个英