0

I'm trying to use https://github.com/yt-dlp/yt-dlp library and add it to the android studio, but I can't get it to work

What I understood from the research I did was that I would use java ProcessBuilder and give it the path of the file Before that, I wrote code to copy the lib file from the assets files to the internal storage, and then give it to the proccess builder as a command

 String FILE_NAME="yt-dlp_linux_armv7l";
        File  outputFile;

        /////////////
        try {
            InputStream inputStream = assetManager.open(FILE_NAME);

            // Write the yt_dlp file to a local file in the application's data directory
             outputFile = new File(context.getFilesDir(), FILE_NAME);
            outputFile.setExecutable(true);
            OutputStream outputStream = new FileOutputStream(outputFile);
            byte[] buffer = new byte[2048];
            int length;
            while ((length = inputStream.read(buffer)) > 0) {
                outputStream.write(buffer, 0, length);
            }
            outputStream.flush();
            outputStream.close();
            inputStream.close();
            //important
            outputFile.setExecutable(true);

        }
        catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

**excute command **

ist<String> command = new ArrayList<>();
        command.add(**outputFile.getAbsolutePath() **);
        command.add(videoUrl);

        ProcessBuilder pb = new ProcessBuilder(command);
        pb.redirectErrorStream(true);

        try {
            Process process = pb.start();

            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
                return line;
            }
            try {
                process.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
                return e.getMessage();
            }
        } catch (IOException e) {
            e.printStackTrace();
            return e.getMessage();
        }

whatever prebuilt file type i try it doesn't work

if i use aarch64 file

if i use linux_armv7l from

avaliable lib prebuild files

i want to make "linux_armv7l" or "aarch64" prebuild files to work with android app

  • android studio has nothing to do with it – user253751 Apr 25 '23 at 14:50
  • Android Studio is an IDE that helps to develop and build apps. If you want to make it "work witth android studio" this means to develop a plugin for AS (what you don't want). You simply want to execute an executable (that is included in the APK) from within your app. Not sure if execution is still possible on recent Android versions, please see https://stackoverflow.com/questions/66933528/running-binary-files – Robert Apr 25 '23 at 15:14
  • i mean that i need the app run the library – melad samir Apr 25 '23 at 15:33

0 Answers0