2

I'm developing a php function for execute a command that's build gradle project Android.

But to be clear I want to create a small system can modify a android project source and generate the APK project by build the gradle.

I do a lot of search about it and I found some close question but not with this command.

This is my function. It's really simple, I have already installed gradle tools in my server, and the command runs successfully in my terminal

function generator(){
    exec('cd /home/my/AndroidStudioProjects/BetaProject/;./gradlew assembleDebug 2>&1',$out,$err);
    var_dump($out); 
    var_dump($err); 
}

But, when I execute it with php it's gives me this :

string(955) "Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: /usr/sbin/.gradle/wrapper/dists/gradle-2.4-all/3i2gobhdl0fm2tosnn15g540i0/gradle-2.4-all.zip.lck (No such file or directory) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78) at org.gradle.wrapper.Install.createDist(Install.java:47) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48) Caused by: java.io.FileNotFoundException: /usr/sbin/.gradle/wrapper/dists/gradle-2.4-all/3i2gobhdl0fm2tosnn15g540i0/gradle-2.4-all.zip.lck (No such file or directory) at java.io.RandomAccessFile.open0(Native Method) at java.io.RandomAccessFile.open(RandomAccessFile.java:316) at java.io.RandomAccessFile.(RandomAccessFile.java:243) at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:49) ... 3 more "

If there's any solution or some advice, I will be so glad.

Thanks

3
  • Check your environmental path by php_info().Terminal and php have different value. Commented Dec 26, 2015 at 12:43
  • thanks , but i had check my path by ls command and yes my path is inside my php project but that's not problem because i have use cmd for going to gradle directory ! and i tested that in terminal everything is ok but with exec gives me that error. Commented Dec 26, 2015 at 13:34
  • Did you ever figure this out? Commented Apr 27, 2020 at 10:30

2 Answers 2

2

try this:

function generator(){

        exec('sh /home/my/AndroidStudioProjects/BetaProject/gradlew assembleDebug 2>&1',$out,$err);
        var_dump($out); 
        var_dump($err); 
}
Sign up to request clarification or add additional context in comments.

Comments

0

I was facing the same issue, and I fixed it just by giving apache permission to execute these scripts by changing the owner of the directory where these files reside

It's going to be something like this:

sudo chown -R www-data your-directory/ 

I hope this is going to work for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.