Initialize the Gameball SDK
Before you can register customers, track events, or show the profile widget, you must initialize the Gameball Android SDK with your configuration. Initialization is typically done once in yourApplication class.
Application-Level Initialization
Create (or update) yourApplication class and initialize Gameball in onCreate.
Configuration Parameters
Your Gameball API key from the dashboard. Required.
Language code for SDK localization (for example, “en”, “ar”, “fr”). Required.
Platform identifier. Defaults to
"android".Your Gameball shop identifier for multi-shop setups.
Optional Session Token used for secure authentication and automatic v4.1 endpoint routing.
Optional custom API endpoint prefix for advanced configurations.
Validation Rules
GameballConfig requires:- apiKey cannot be null
- lang cannot be null
Environment Configuration (Test vs Production)
You can switch between Test and Production keys based on your build type:Always use your Test Key in development and staging builds, and your Production Key only in live builds.
Common Initialization Issues
SDK Not Initialized Error
SDK Not Initialized Error
Error:
API key is required for customer initialization Cause: GameballApp.getInstance(context).init(config) was not called before other SDK methods.Solution: Ensure initialization happens in your Application.onCreate() and that the Application class is correctly registered in AndroidManifest.xml.Invalid API Key
Invalid API Key
Symptoms: Requests failing with authentication or 4xx errors. Solution: Verify the API key used in
GameballConfig matches the key shown in your Gameball dashboard (and that you are using the correct environment key: Test vs Production).