Skip to content

Commit d1fa4dd

Browse files
oschwaldclaude
andcommitted
feat: Require account ID configuration for sample app
Move account ID from hardcoded value to local.properties configuration. The sample app now requires maxmind.account.id to be set, showing an error message if not configured. Configuration in local.properties: maxmind.account.id=123456 This ensures developers use their own account ID rather than a demo value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6b0b243 commit d1fa4dd

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

SETUP.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,32 @@ device-android/
188188
└── README.md # Main documentation
189189
```
190190

191-
## Local Development Server
191+
## Sample App Configuration
192192

193-
The sample app can be configured to connect to a local development server
194-
instead of the production MaxMind servers. This is useful for testing the SDK
195-
against a local backend.
193+
The sample app requires configuration via `local.properties` (gitignored).
196194

197-
### Quick Start
195+
### Required Configuration
196+
197+
Add your MaxMind account ID to `local.properties`:
198+
199+
```properties
200+
maxmind.account.id=123456
201+
```
202+
203+
Without this, the sample app will show an error when you try to initialize the
204+
SDK.
205+
206+
### Local Development Server
207+
208+
The sample app can optionally connect to a local development server instead of
209+
the production MaxMind servers.
210+
211+
#### Quick Start
198212

199213
1. **Add to `local.properties`**:
200214

201215
```properties
216+
maxmind.account.id=123456
202217
debug.server.url=https://localhost:8443
203218
debug.ca.cert=/path/to/your/ca.crt
204219
```
@@ -219,13 +234,14 @@ against a local backend.
219234

220235
Add these to `local.properties` (gitignored):
221236

222-
| Property | Description |
223-
| ------------------ | -------------------------------------------- |
224-
| `debug.server.url` | Server URL (e.g., `https://localhost:8443`) |
225-
| `debug.ca.cert` | Path to CA certificate for self-signed HTTPS |
237+
| Property | Required | Description |
238+
| -------------------- | -------- | -------------------------------------------- |
239+
| `maxmind.account.id` | Yes | Your MaxMind account ID |
240+
| `debug.server.url` | No | Server URL (e.g., `https://localhost:8443`) |
241+
| `debug.ca.cert` | No | Path to CA certificate for self-signed HTTPS |
226242

227-
Both properties are optional. Without them, the sample app connects to
228-
production MaxMind servers.
243+
Without the optional debug properties, the sample app connects to production
244+
MaxMind servers.
229245

230246
### ADB Reverse Port Forwarding
231247

sample/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ if (localPropertiesFile.exists()) {
1616
}
1717
val debugServerUrl = localProperties.getProperty("debug.server.url", "")
1818
val debugCaCertPath = localProperties.getProperty("debug.ca.cert", "")
19+
val accountId = localProperties.getProperty("maxmind.account.id", "0")
1920

2021
android {
2122
namespace = "com.maxmind.device.sample"
@@ -40,6 +41,7 @@ android {
4041
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4142

4243
buildConfigField("String", "DEBUG_SERVER_URL", "\"$debugServerUrl\"")
44+
buildConfigField("int", "MAXMIND_ACCOUNT_ID", accountId)
4345
}
4446

4547
buildTypes {

sample/src/main/java/com/maxmind/device/sample/MainActivity.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,18 @@ class MainActivity : AppCompatActivity() {
6767
return
6868
}
6969

70+
// Check that account ID is configured
71+
if (BuildConfig.MAXMIND_ACCOUNT_ID == 0) {
72+
val errorMsg = "Account ID not configured. Add maxmind.account.id to local.properties"
73+
appendLog("$errorMsg")
74+
showMessage(errorMsg)
75+
return
76+
}
77+
7078
// Create SDK configuration
71-
// Note: Replace with your actual MaxMind account ID
7279
val configBuilder =
7380
SdkConfig
74-
.Builder(123456) // Demo account ID - replace with real one
81+
.Builder(BuildConfig.MAXMIND_ACCOUNT_ID)
7582
.enableLogging(true)
7683

7784
// Use debug server URL if configured in local.properties

0 commit comments

Comments
 (0)