Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing -P parameters to gradle from android studio

Is there a functionality inside android studio to do things like this. Basically my gradle script reads parameter named version based on which it sets dependency version of a certain library. So when I do gradlew -Pversion=‘1.2.3' I get this string inside gradle. But this only works if I invoke gradle from console.

Is there a way to pass parameters to gradle when started using configuration for project inside Android Studio (pressing little play triangle)?

NOTE:I did find Gradle VM options and Script prameters under default configs but adding -Pversion=‘1.2.3' there doesn't seem to have an effect.

like image 885
Igor Čordaš Avatar asked Oct 19 '15 13:10

Igor Čordaš


2 Answers

In order to provide parameter to run option of Android Studio you should setup them under AndroidStudios Compile Preferences

AndroidStudio > Preferences...

Under Compiler: ComandLineOptions enter image description here

like image 79
Rostyslav Roshak Avatar answered Nov 20 '22 20:11

Rostyslav Roshak


Run > Edit Configurations..

enter image description here

Replace "abcdef" in Script parameters by your params.

like image 12
ABS Avatar answered Nov 20 '22 19:11

ABS