android - Declare/use variable in gradle file - use it in java -


i have in gradle file :

string packagename = com.test.free 

i want string variable packagename use in java class. use android studio 1.5.1.

is possible? how can transfer string gradle java ?

i have read similar questions here none of solutions worked.

if value applicationid, available buildconfig.application_id.

otherwise, can add own custom fields buildconfig. these can include dynamic values:

import static java.util.uuid.randomuuid  apply plugin: 'com.android.application'  android {     compilesdkversion 23     buildtoolsversion "23.0.2"      defaultconfig {         applicationid "com.commonsware.myapplication"         minsdkversion 21         targetsdkversion 23         versioncode 1         versionname "1.0"     }      buildtypes {         debug {             buildconfigfield "string", "foo", '"'+randomuuid()+'"'         }           release {             buildconfigfield "string", "foo", '"a49f05b4-f55a-4066-a107-9098c9350f43"'         }     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -