I am using gradle 2.4 and androidStudio 1.3.2. And in your code, just call the variables like this:īuildConfig.USERNAME BuildConfig.PASSWORD.After this, you need to sync your gradle.The “ USERNAME” and “ PASSWORD” will be the variables in your code and the testUsername and testPassword should be the same variable which you are using in your gradle.properties file (above).īuildConfigField "String", " USERNAME", testUsernameīuildConfigField "String", " PASSWORD", testPassword In your adle file (Remember, you can have many adle file, so first try to find the one that you want to share with all projects or the one which you will use only in your project > buildTypes > debug, as it is showed in the structure below).TestUsername="username" testPassword="password" In your gradle.properties create the environment variables (You can find this file inside of your Android Studio project or in your /Users/ Your Username/.gradle).Today I will post some simple steps to have some environment variables in your android studio project. So, if you have some confidential data to use in your android tests, you can hide the password, username or if you just want to have some environment variables separated from your project, just follow these steps: The execution environment is the set of environment variables and Android system properties that influence program execution.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |