Skip to content

fix the bug please #317

Description

@iyjaa

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

  1. Create/open an Android project in rv2ide.
  2. Set compileSdk = 37 and targetSdk = 37 in build.gradle.kts.
  3. Ensure Android SDK Platform 37 is installed.
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions