NumberFormatException when parsing api-versions.xml for API level 37.0 during project setup
Environment
- IDE: rv2ide
- Android Gradle Plugin (AGP): 9.2.0
- Kotlin: 2.1.0
- Compose BOM: 2025.10.01
- compileSdk / targetSdk: 37
- Device: Oppo A3s (refurbished)
- OS: Android 8.1 (Oreo)
Description
Project setup fails with a NumberFormatException when the target/compile SDK is set to API level 37. The IDE's internal API-versions parser expects a plain integer string, but Google's api-versions.xml for API 37 now uses a decimal-formatted version string ("37.0"), following Google's updated SDK versioning scheme. This is confirmed by the official AGP 9.1.1 and 9.2.0 release notes, which reference "API level 37.0" as the supported maximum.
Steps to Reproduce
- Create/open an Android project in rv2ide.
- Set
compileSdk = 37 and targetSdk = 37 in build.gradle.kts.
- Ensure Android SDK Platform 37 is installed.
- Sync/setup the project.
Expected Behavior
Project setup completes successfully, correctly parsing the 37.0 version string from api-versions.xml.
Actual Behavior
Project setup fails immediately with the following exception:
Project setup failed: For input string: "37.0"
Exception Details:
Type: java.lang.NumberFormatException
Message: For input string: "37.0"
Stack Trace:
java.lang.NumberFormatException: For input string: "37.0"
at java.lang.Integer.parseInt(Integer.java:608)
at java.lang.Integer.parseInt(Integer.java:643)
at com.tom.rv2ide.xml.internal.versions.ApiVersionsParser.parseAttrs(ApiVersionsParser.kt:175)
at com.tom.rv2ide.xml.internal.versions.ApiVersionsParser.consumeMember(ApiVersionsParser.kt:127)
at com.tom.rv2ide.xml.internal.versions.ApiVersionsParser.consumeStartElement(ApiVersionsParser.kt:94)
at com.tom.rv2ide.xml.internal.versions.ApiVersionsParser.parse(ApiVersionsParser.kt:75)
at com.tom.rv2ide.xml.internal.versions.DefaultApiVersionsRegistry.readApiVersions(DefaultApiVersionsRegistry.kt:71)
at com.tom.rv2ide.xml.internal.versions.DefaultApiVersionsRegistry.forPlatformDir(DefaultApiVersionsRegistry.kt:52)
at com.tom.rv2ide.xml.internal.versions.DefaultApiVersionsRegistry.forPlatformDir(DefaultApiVersionsRegistry.kt:34)
at com.tom.rv2ide.projects.android.AndroidModule.getApiVersions(AndroidModule.kt:296)
at com.tom.rv2ide.projects.android.AndroidModule$readResources$2$resourceFlow$1.invokeSuspend(AndroidModule.kt:274)
at com.tom.rv2ide.projects.android.AndroidModule$readResources$2$resourceFlow$1.invoke(Unknown Source:8)
at com.tom.rv2ide.projects.android.AndroidModule$readResources$2$resourceFlow$1.invoke(Unknown Source:4)
at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
at com.tom.rv2ide.projects.android.AndroidModule$readResources$lambda$4$$inlined$map$1.collect(SafeCollector.common.kt:109)
at kotlinx.coroutines.flow.FlowKt__CollectionKt.toCollection(Collection.kt:22)
at kotlinx.coroutines.flow.FlowKt.toCollection(Unknown Source:1)
at kotlinx.coroutines.flow.FlowKt__CollectionKt.toList(Collection.kt:11)
at kotlinx.coroutines.flow.FlowKt.toList(Unknown Source:1)
at kotlinx.coroutines.flow.FlowKt__CollectionKt.toList$default(Collection.kt:11)
at kotlinx.coroutines.flow.FlowKt.toList$default(Unknown Source:1)
at com.tom.rv2ide.projects.android.AndroidModule.readResources(AndroidModule.kt:284)
at com.tom.rv2ide.projects.internal.ProjectManagerImpl$setupProject$4$jobs$1$1.invokeSuspend(ProjectManagerImpl.kt:126)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:829)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
Root Cause (Analysis)
ApiVersionsParser.kt (line 175) uses Integer.parseInt() to parse a version attribute value from api-versions.xml. This works fine for integer-only version strings (e.g. "36") but throws when the value is a decimal-formatted string such as "37.0", which is the format used in the API 37 platform's api-versions.xml.
Suggested Fix
Update ApiVersionsParser.parseAttrs() to handle decimal-formatted version strings — e.g. by parsing with Double.parseDouble() / .toFloat() and truncating to an integer where needed, or by stripping/splitting on "." before calling Integer.parseInt().
Workaround (for other users hitting this)
Downgrade compileSdk / targetSdk to 36 until the parser is patched.
References
NumberFormatException when parsing api-versions.xml for API level 37.0 during project setup
Environment
Description
Project setup fails with a
NumberFormatExceptionwhen the target/compile SDK is set to API level 37. The IDE's internal API-versions parser expects a plain integer string, but Google'sapi-versions.xmlfor API 37 now uses a decimal-formatted version string ("37.0"), following Google's updated SDK versioning scheme. This is confirmed by the official AGP 9.1.1 and 9.2.0 release notes, which reference "API level 37.0" as the supported maximum.Steps to Reproduce
compileSdk = 37andtargetSdk = 37inbuild.gradle.kts.Expected Behavior
Project setup completes successfully, correctly parsing the
37.0version string fromapi-versions.xml.Actual Behavior
Project setup fails immediately with the following exception:
Root Cause (Analysis)
ApiVersionsParser.kt(line 175) usesInteger.parseInt()to parse a version attribute value fromapi-versions.xml. This works fine for integer-only version strings (e.g."36") but throws when the value is a decimal-formatted string such as"37.0", which is the format used in the API 37 platform'sapi-versions.xml.Suggested Fix
Update
ApiVersionsParser.parseAttrs()to handle decimal-formatted version strings — e.g. by parsing withDouble.parseDouble()/.toFloat()and truncating to an integer where needed, or by stripping/splitting on"."before callingInteger.parseInt().Workaround (for other users hitting this)
Downgrade
compileSdk/targetSdkto 36 until the parser is patched.References