An example app using the Ampli Android SDK
You will need to do the following before running the app.
-
Configure Android SDK path
- Set
ANDROID_SDK_ROOT
in your environment, or - Create a
local.properties
file and setsdk.dir
to your Android SDK path. See local.properties.example.
- Set
-
Update secrets.xml with your Amplitude API key:
<?xml version="1.0" encoding="utf-8"?> <resources> <string name="AMPLITUDE_API_KEY">your-amplitide-api-key</string> </resources>
- Put
google-services.json
into app folder (Add Firebase to your Android project) - Uncomment a line in app-level app/build.gradle:
// For Firebase // Uncomment next line: id 'com.google.gms.google-services' // Google Services plugin
- Uncomment a line in App.kt:
/** * Firebase analytics support */ ampli.client.addEventMiddleware(FirebaseMiddleware())
Run the application using Android Studio or your favorite IDE.
If you want to use your own tracking plan to generate the Ampli SDK:
npm i -g @amplitude/ampli
ampli pull
- Update MainActivity.kt to track your events.
- README.md - you are here *
- src/main/java/
- com/example/ampliapp/
- MainActivity.kt - Example user app using Amply SDK. A good place to start.
- App.kt - Initialization logic.
- com/amplitude/ampli/
- Ampli.kt - Generated SDK, don't modify by hand. Update with
ampli pull
- Ampli.kt - Generated SDK, don't modify by hand. Update with
- com/example/ampliapp/