Skip to content

Other SDK customizations for Android and FireOS

This reference article covers additional customization and configuration options such as verbose logging, suppressing logging, and how to implement multiple API keys.

Using R8/ProGuard with Braze

Code shrinking configuration is automatically included with your Braze integration.

Client apps that obfuscate Braze code must store release mapping files for Braze to interpret stack traces. If you want to continue to keep all Braze code, add the following to your ProGuard file:

1
2
-keep class bo.app.** { *; }
-keep class com.braze.** { *; }

Logging

By default, the Braze Android SDK log level is set to INFO. You can suppress these logs or set a different log level, such as VERBOSE, DEBUG, or WARN.

Enabling logs

To help troubleshoot issues in your app, or reduce turnaround times with Braze Support, you’ll want to enable verbose logs for the SDK. When you send verbose logs to Braze Support, ensure they begin as soon as you launch your application and end far after your issue occurs.

Keep in mind, verbose logs are only intended for your development environment, so you’ll want to disable them before releasing your app.

To enable logs directly in your app, add the following to your application’s onCreate() method before any other methods.

1
BrazeLogger.setLogLevel(Log.MIN_LOG_LEVEL);
1
BrazeLogger.logLevel = Log.MIN_LOG_LEVEL

Replace MIN_LOG_LEVEL with the Constant of the log level you’d like to set as your minimum log level. Any logs at a level >= to your set MIN_LOG_LEVEL will be forwarded to Android’s default Log method. Any logs < your set MIN_LOG_LEVEL will be discarded.

Constant Value Description
VERBOSE 2 Logs the most detailed messages for debugging and development.
DEBUG 3 Logs descriptive messages for debugging and development.
INFO 4 Logs informational messages for general highlights.
WARN 5 Logs warning messages for identifying potentially harmful situations.
ERROR 6 Logs error messages for indicating application failure or serious issues.
ASSERT 7 Logs assertion messages when conditions are false during development.

For example, the following code will forward log levels 2, 3, 4, 5, 6, and 7 to the Log method.

1
BrazeLogger.setLogLevel(Log.VERBOSE);
1
BrazeLogger.logLevel = Log.VERBOSE

To enable logs in the braze.xml, add the following to your file:

1
<integer name="com_braze_logger_initial_log_level">MIN_LOG_LEVEL</integer>

Replace MIN_LOG_LEVEL with the Value of the log level you’d like to set as your minimum log level. Any logs at a level >= to your set MIN_LOG_LEVEL will be forwarded to Android’s default Log method. Any logs < your set MIN_LOG_LEVEL will be discarded.

Constant Value Description
VERBOSE 2 Logs the most detailed messages for debugging and development.
DEBUG 3 Logs descriptive messages for debugging and development.
INFO 4 Logs informational messages for general highlights.
WARN 5 Logs warning messages for identifying potentially harmful situations.
ERROR 6 Logs error messages for indicating application failure or serious issues.
ASSERT 7 Logs assertion messages when conditions are false during development.

For example, the following code will forward log levels 2, 3, 4, 5, 6, and 7 to the Log method.

1
<integer name="com_braze_logger_initial_log_level">2</integer>

Verifying verbose logs

To verify that your logs are set to VERBOSE, check if V/Braze occurs somewhere in your logs. If it does, then verbose logs have been successfully enabled. For example:

1
2077-11-19 16:22:49.591 ? V/Braze v9.0.01 .bo.app.d3: Request started

Suppressing logs

The default log level for the Braze Android SDK is INFO. To suppress all logs for the Braze Android SDK, call BrazeLogger.SUPPRESS in your application’s onCreate() method before any other methods.

1
BrazeLogger.setLogLevel(BrazeLogger.SUPPRESS);
1
BrazeLogger.setLogLevel(BrazeLogger.SUPPRESS)

Multiple API keys

The most common use case for multiple API keys is separating API keys for debug and release build variants.

To easily switch between multiple API keys in your builds, we recommend creating a separate braze.xml file for each relevant build variant. A build variant is a combination of build type and product flavor. Note that by default, a new Android project is configured with debug and release build types and no product flavors.

For each relevant build variant, create a new braze.xml for it in src/<build variant name>/res/values/:

1
2
3
4
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="com_braze_api_key">REPLACE_WITH_YOUR_BUILD_VARIANT_API_KEY</string>
</resources>

When the build variant is compiled, it will use the new API key.

See the runtime configuration documentation for setting an API key in code.

HOW HELPFUL WAS THIS PAGE?
New Stuff!