4

When I try to start new process, it finds a file to execute (as before it threw different exception), but throws an exception access denied. Here is a similar problem but only rights and permisions part makes sense to me from the answers that could be a problem. There was also an idea not to set RedirectStandardOutput to true for purpose of finding the error, so I disabled this row. Do I need some special permissions, manifest entries or whatever similar to enable starting new process from my app on android?

This is my code:

try
{
    string strToFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName = "stockfish-8-armeabi-v7a";

    ProcessStartInfo psi = new ProcessStartInfo();
    psi.FileName = System.IO.Path.Combine(strToFolder, fileName);
    psi.UseShellExecute = false;
    psi.CreateNoWindow = true;
    psi.WorkingDirectory = strToFolder;
    //psi.RedirectStandardOutput = true;
    //psi.RedirectStandardError = true;

    stockfishProcess = new System.Diagnostics.Process();
    stockfishProcess.StartInfo = psi;
    stockfishProcess.Start();
}
catch (Exception e)
{
    string estr = e.ToString();
    initialized = false;
}

And this is the exception text

System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/data/user/0/AlienChessAndroid.AlienChessAndroid/files/stockfish-8-armeabi-v7a', CommandLine='', CurrentDirectory='/data/user/0/AlienChessAndroid.AlienChessAndroid/files', Native error= Access denied at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x0018b] in /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/System/System.Diagnostics/Process.cs:737

Ahmad Aghazadeh
  • 16,571
  • 12
  • 101
  • 98
hoacin
  • 340
  • 1
  • 2
  • 19
  • What Android version and ROM are you using? – Samuel Tulach Jun 12 '17 at 18:01
  • @Samuel Tulach My phone for testing is android 6.0 with default ROM installed by manufacturer, phone Doogee x5 max pro. – hoacin Jun 12 '17 at 18:22
  • Did you tested it on other phone? I thing, that the code is right and the error is caused by some ROM specific requirements. – Samuel Tulach Jun 12 '17 at 18:29
  • @Samuel Tulach I didn't. Does it make sense to try it on emulator (I don't use it so quite some work to set it up)? I will look on what you wrote and try something, will take time. Thank you for idea. – hoacin Jun 12 '17 at 18:46
  • What should happen when you start this process? Is it special file "stockfish-8-armeabi-v7a" ? – Yuri S Jun 18 '17 at 01:31
  • @Yuri S It should be executable file communicating via standard input output. Unfortunately there is no much help on their website, how to use it. I got this advice how to run the file on chess stack exchange forum from tech guy working with these things too. – hoacin Jun 18 '17 at 06:48

2 Answers2

2

Trying to deal with my problem various ways I accidentally came to very easy solution to my problem. These two lines were missing before my code.

string[] cmd = { "chmod", "744", Path.Combine(strToFolder, fileName) };
Java.Lang.Runtime.GetRuntime().Exec(cmd);

Default file permission didn't allow executing the file so it had to be changed.

hoacin
  • 340
  • 1
  • 2
  • 19
0

My guess is that what you are doing is not really what you are trying to achieve.
You are starting a process with native java library file (stockfish-8-armeabi-v7a).
This is not how you consume native libraries (have to use the PInvoke).

Look here and here.

igorc
  • 2,024
  • 2
  • 17
  • 29
  • This possibility also came to my mind, but when I was asking on chess forum, the guy who I expect to understand the problem told me it should be started this way. There is nothing written on their web pages, what file it is and how to use it. That's very annoying. – hoacin Jun 18 '17 at 06:42