I would like to use an external executable within my android app.
It is distributed for different platforms and under windows it's a console program that can be used in this way
For Android the executable is called senpai-arm. I moved it to an Android folder and tried to start it in a similar way to the link above but it won't start.
String storage = context.getFilesDir().getAbsolutePath();
// Create the proccess in JAVA
Process proc = Runtime.getRuntime().exec(storage+ "/senpai-arm");
error message below:
java.io.IOException: Error running exec().
Command: [/data/user/0/com.example.jp.fanfar/files/senpai-arm] Working Directory: null Environment: nul
cause: Permission denied
Sorry that I didn't observe the cause Permission denied in my original question.
I rephrase my question a bit.
Is it possible to start a program like this?
What permissions do I need? I have read/write external storage permission.
(I have the source code in C++ and read about NDK but I was hoping to take a shortcut by using the distributed executable instead.)
Related
I'm trying to capture sound from microphone via Java Sound API.
I'm using sample code from github and it works perfect on Windows system, but when it runs on MacOS - audio-line buffer returns zero-bytes.
Also if I compile project to jar and run it via administrator permission - appears a message to give access to microphone and after I grant it - all works.
So the question is how to make permission request from code and run app without sudo?
Thanks!
BTW, you have to use the default terminal that comes with mac to execute jar file. That will worked.
The third party terminal, such as iTerm, it's not ok.
Today when I was doing my project using android studio, a blue screen suddenly appears and system get restarted automatically. And now when I tried to run my app using emulator, the AVD is not running and I get an error as below. Anyone faced this before ? How do I fix this?
ProcessNotCreatedException: Unexpected error while launching AVD:
Cannot run program
"C:\Users\tongws\AppData\Local\Android\sdk\tools\emulator.exe":
CreateProcess error=216, This version of %1 is not compatible with the
version of Windows you're running. Check your computer's system
information to see whether you need a x86 (32-bit) or x64 (64-bit)
version of the program, and then contact the software publisher
Wnen I click the Android Device Monitor, nothing happen also...
Found the following solution.
Go to the following directory in your computer:
C:\Users.android\avd
Inside this directory you will find all files and directories with the definition and content of your avd machines-
Now do the basic troubleshooting steps:
-check if the avd directory exists and if it contains a file with the name "sdcard.img".
-if the file exists, try to rename it (to check if its locked) and then go to eclipse and ask to create a new sd card.
-if it fails, try to create manualy a file with that name to check premissions.
good luck
You have a computer problem not related to AVD
ProcessNotCreatedException :Exception thrown when attempting to retrieve the result of a task that aborted by throwing an exception.
Because of their usefulness and ubiquity, EXE files are commonly used
as a method of delivery for virus / malware infection. Often, viruses
will be disguised as a benign EXE file (such as emulator.exe) and
distributed through SPAM email or malicious websites, which can then
infect your computer when executed (eg. when you double-click the EXE
file). In addition, viruses can infect, replace, or corrupt existing
EXE files, which can then lead to error messages when
related programs are executed. Thus, any executable files that you
download to your PC should be scanned for viruses before opening -
even if you think it is from a reputable source.
Read SO Answer .
What should you do
FORMAT Your System
Install Android Studio (Set Latest Version With Proper JDK Path)Note that you need to have JDK 6 or higher installed.
You can use Intel x86 Emulator Accelerator (HAXM installer) or Genymotion .
IF YOU HAVE MULTIPLE DRIVES, THE DRIVE WHERE THE OS IS INSTALLED IS
NEEDED TO BE FORMATTED, SO YOU SHALL LOSS ALL DATA OF THAT DRIVE. I
SUGGEST YOU TO TAKE A BACK UP OF ALL YOUR IMPORTANT DATA STORED IN
THAT DRIVE, INTO OTHER DRIVES WHICH WOULD REMAIN UNCHANGED. ON THE
OTHER HAND, IF YOU HAVE ONLY ONE DRIVE, THEN ALL YOUR DATA WILL GET
ERASED WHILE FORMATTING .
I am trying to execute a Java program on inserting a USB Flash Drive and pass the path of the USB Flash Drive as a parameter to my Java program. To achieve this, I have written a 'udev' rule in both '/etc/udev/rules.d' and '/lib/udev/rules.d' with the names '99-thumbdrive.rules' and '98-thumbdrive.rules'.
The rule is as follows:
ACTION=="add", KERNEL=="sd?1", SUBSYSTEM=="usb", RUN="/home/nouman/Data/NSProj/shell.sh"
The 'shell.sh' file has been made executable by using 'sudo chmod +x shell.sh'
When I insert my Flash Drive and run the command 'udevadm test /dev/bus/003/008', I see my rules being read.
read rules file: /lib/udev/rules.d/98-thumbdrive.rules
read rules file: /etc/udev/rules.d/99-thumbdrive.rules
My shell.sh file is as follows
#!/bin/bash
java USB
I have been trying this for a couple of days now and have read most of the posts online but am unable to run my script. Kindly help me out.
I am running a webservice using glassfish server on Ubuntu. The problem is - it is required to access a directory outside of its shared resource. Presently it is giving an error saying "Permission Denied". I set a permission into server.policy too.
grant codeBase "/home/glassfish/glassfish/test/-" {
permission java.security.AllPermission;
};
But it seems not working.
I tried <property name="alternatedocroot_1" value="from=*.* dir=/home/glassfish/glassfish/test"/> , but it seems it is giving only reading permission. I need write permission also. So my question is how can I set the write permission ?
Thanks.
This is not a JavaSecurity problem so you shouldn't need to tweak anything in that regard.
FWIW our web-apps deployed to GF on various flavors of Windows write to directories which are outside of the 'Application' directory using File APIs. alternatedocroot pertains to GF serving static content using the DefaultServlet not to writing outside of the Application deployment directory.
On windows when you run as Service you have to be careful that the 'Run As' user has proper permissions to write to the target directory, on Unix you need to make sure the user set by your rc (init.d) scripts that runs asadmin.sh has permissions to read/write to the target directory.
I would double check the the user that the java process GF is running under has rwx permissions on the directory your are trying to write to. Make sure that user can write to the target folder. To test this you can su to the user and use the 'touch' command like so: touch /tmp/test and verify write permissions that way. Verify read permissions similarly by running 'ls -l /tmp/test' to make sure you can read it.
See what 'ps -ef | grep java' shows to verify the user running the GF java process. Additionally in your code try specifying a full path to the test file, eg. File test = new File("/tmp/test");
Are you running GF from an rc script or are you starting it using asadmin.sh from a shell prompt? If you are running an rc script check that your rc script is really running it as the user you expect it to be.
I'm trying to test the behavior of my application when it cannot access some files due to missing permissions.
Is it possible to change file/folder permissions on an android emulator using FileExplorer in DDMS perspective?
To change permissions in the emulator you need to use the adb shell command from your adroid-sdk platform-tools. In the android shell you can enter the command su to get root access. Now you can see and change the permissions with the normal unix commands chmod
Note, that the system folder in Android is mounted read-only. You would have to remout it read-write after this tutorial:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Be careful in anyway to use only writable filesystems like /data or sdcardfor your application data since using restricted folders can have negative side effects in a productive environment!