Trouble opening a ROM with Android RetroArch (using ADB shell)

Hi, I would like to open games in a single blow, (without the steps retroarch–>selecting core–>selecting game…) and the best way I found right now is to open the emulator through ADB shell (on pc I connect my android in developer mode with usb, on Android Studio, and there I can insert commands to create the equivalent of cmd batch file on windows). Right now this is my best try so far, but it actually just launch the emulator (no loaded game or core whatsoever):

adb shell am start -n com.retroarch/.browser.mainmenu.MainMenuActivity -e rom_file "/storage/emulated/0/Books/MarioSlam.nds"

I’ll breakdown the different parts so anyone that want to repeat can try himself/herself

  • adb shell am start command to launch an app
  • -n com.retroarch the actual name of the app as the system knows it (found it using command “adb shell pm list packages”)
  • /.browser.mainmenu.MainMenuActivity the actual intent (a function) u want the app to use (this one is the only one avaiable in my case and set up the “main activity” of the app retro arch, found with “adb shell dumpsys package com.retroarch”)
  • -e rom_file “/storage/emulated/0/Books/MarioSlam.nds” (the extra argument you include with “-e” that in this case is the path to the rom I want to be loaded)

I also read the possibility to insert the desired core to use with -e LIBRETRO “/data/user/0/com.retroarch/cores/melondsds_libretro_android.so” and also that I can use -e PATH “rom_directory_path” instead of the one I used. But I keep getting the same results. Any help?

(The final idea would be to use commands like this inside external memories like nfc tag to emulate the idea of game cartirdge, but this would be the first step anyway )

1 Like

I might be wrong, but I believe that opening a *.cmd (containing command line entries) as content, is cross-platform.

Personally, I would use a front-end and not worry about it. :grin:

It’s not pretty, but it’s doable:

adb shell am start --user 0 -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.retroarch/com.retroarch.browser.retroactivity.RetroActivityFuture --es "LIBRETRO" "path_to_cores/core_name_android.so" --es "CONFIGFILE" "path_to_config/retroarch.cfg" --es "ROM" "path_to_rom/romfile.nds" --es "IME" com.android.inputmethod.latin/.LatinIME --activity-clear-task --activity-clear-top --activity-no-history

I adapted the correct paths from your command and sadly it open up retroarch but bring to a black screen. I think he reached the point he s trying to load core but theres something wrong and get stuck o.O

I think you re right. I was using this method because an app called Tasker that let you read from tag nfc even shell command/adb commands (like I said I wanted to save different “shortcuts” to launch retroarch in some tag nfc, and using them as game cartirdge to open games directly with retroarch). I fear it need my android to be rooted tho. But I don’t have any other good idea to recreate the same idea. Have you any?

Permissions can definitively be an issue.

The command assumes you have normal Retroarch installed, which uses com.retroarch. It could also be: com.retroarch.aarch64 or com.retroarch.ra32 if you have a different Retroarch flavor installed.

You need to ensure retroarch has file access to wherever the rom is saved. Make sure you can navigate to the ROM in Retroarch.

path_to_cores is likely something like /data/user/0/com.retroarch/cores/ but varies on Android flavor. You can find it in Retroarch Directory settings:

path_to_config is likely something like /storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg but varies based on Android flavor. You can find it by hitting ‘Save Configuration’ in Retroarch, and it will print out where the save path is: