Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch app with environment variable

I'm writing a C/C++ Android app. One of the libraries I'm using prints additional debugging information depending on whether an environment variable is set. Is there's any way to set one?

I was hoping that the launch target could be configured with an environment variable in Android Studio. Under Launch Options, there's an option to provide flags to the am start call but Activity Manager doesn't provide any way of setting an environment variable prior to launch.

like image 556
spaaarky21 Avatar asked Oct 16 '25 04:10

spaaarky21


1 Answers

Include a wrap.sh file in your APK: https://developer.android.com/ndk/guides/wrap-script.html

This only works for debuggable APKs, but given that you want it for logging that's probably for the best anyway.

like image 100
Dan Albert Avatar answered Oct 18 '25 18:10

Dan Albert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!