PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 5, 2022

[FIXED] How to get an ENV var available in project which uses Android.mk

 November 05, 2022     android, environment-variables, makefile     No comments   

Issue

I have an Android project which uses Android.mk files for the setup. I would like to introduce Build Variants to the project and based on a build var such as BUILD_BRAND to perform some UI changes.

My case is: I have BUILD_BRAND exported on my Ubuntu in the .bashrc. If I echo $BUILD_BRAND I would get the value printed in the terminal.

I also do $(warning $(BUILD_BRAND)) and I can see during the build the value is printed so it is available.

But when I try to do System.getEnv("BUILD_BRAND"); in an activity, a null is returned.

The question is how to make this value under BUILD_BRAND to become globally available to the project.

Thanks!


Solution

In my case the solution was to use SystemProperties.get("the.property.name").

The "the.property.name" was set in the Makefile.mk located in the core.

I also find out that I can export ENV vars to the project during build time using the same Makefile.mk.

N.B - You can't access an env var during runtime directly using System.getEnv() !



Answered By - Top4o
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing