You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Kotlin Compose UI程序时遇Failed to choose DirectX12 Adapter问题求助

Kotlin Compose Desktop 运行时出现「Failed to choose DirectX12 Adapter」问题

我使用IntelliJ IDE进行Kotlin开发,在学习Compose UI教程并运行基础程序时,弹出「Failed to choose DirectX12 Adapter」提示。程序窗口能正常打开并运行,但希望解决这个适配器选择的问题。

运行代码

import androidx.compose.material.MaterialTheme
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application

@Composable
@Preview
fun App() {
    var text by remember { mutableStateOf("Hello, World!") }

    MaterialTheme {
        Button(onClick = {
            text = "Hello, Desktop!"
        }) {
            Text(text)
        }
    }
}

系统信息

Time of this report: 2/9/2023, 22:18:43
         Machine name: DESKTOP-JQ7CR2F
           Machine Id: {B31A9997-C49B-4C8D-84B7-67A3C21C6D33}
     Operating System: Windows 10 Home 64-bit (10.0, Build 19044) (19041.vb_release.191206-1406)
             Language: English (Regional Setting: English)
  System Manufacturer: To Be Filled By O.E.M.
         System Model: To Be Filled By O.E.M.
                 BIOS: BIOS Date: 07/27/15 17:53:10 Ver: 04.06.05 (type: BIOS)
            Processor: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz (4 CPUs), ~3.3GHz
               Memory: 8192MB RAM
  Available OS Memory: 8128MB RAM
            Page File: 14425MB used, 8359MB available
          Windows Dir: C:\Windows
      DirectX Version: DirectX 12
  DX Setup Parameters: Not found
     User DPI Setting: 96 DPI (100 percent)
   System DPI Setting: 96 DPI (100 percent)
      DWM DPI Scaling: Disabled
             Miracast: Not Available
  • Microsoft Graphics Hybrid: 不支持
  • DirectX Database Version: 1.0.8
  • DxDiag Version: 10.00.19041.2075 64bit Unicode

DxDiag备注

Display Tab 1: No problems found.
  Display Tab 2: No problems found.
    Sound Tab 1: No problems found.
    Sound Tab 2: No problems found.
    Sound Tab 3: No problems found.
    Sound Tab 4: No problems found.
      Input Tab: No problems found.

DirectX调试级别

  • Direct3D: 0/4 (零售版)
  • DirectDraw: 0/4 (零售版)
  • DirectInput: 0/5 (零售版)
  • DirectMusic: 0/5 (零售版)
  • DirectPlay: 0/9 (零售版)
  • DirectSound: 0/5 (零售版)
  • DirectShow: 0/6 (零售版)

显示设备

Card name: NVIDIA GeForce 210 
    Manufacturer: NVIDIA
       Chip type: GeForce 210
        DAC type: Integrated RAMDAC
     Device Type: Full Device (POST)
      Device Key: Enum\PCI\VEN_10DE&DEV_0A65&SUBSYS_082E196E&REV_A2
   Device Status: 0180200A 

解决办法

1. 强制切换到OpenGL渲染

你的NVIDIA GeForce 210属于老型号Fermi架构,仅支持DirectX 11.0,不具备DirectX12硬件支持。Compose Desktop默认优先尝试DirectX12,因此会出现适配器选择失败。可以通过JVM参数强制使用OpenGL:

  • 在IntelliJ运行配置的「VM options」中添加:-Dskiko.rendering.api=OPENGL
  • 或在build.gradle.kts中全局配置:
    tasks.withType<JavaExec> {
        jvmArgs("-Dskiko.rendering.api=OPENGL")
    }
    

2. 更新显卡驱动

尽管DxDiag未检测到问题,老显卡的驱动更新可能修复兼容性问题,建议前往NVIDIA官网下载GeForce 210的最新驱动安装。

3. 备选:使用软件渲染

如果上述方法无效,可以尝试禁用硬件加速,使用软件渲染:

  • 添加JVM参数:-Dskiko.rendering.api=SOFTWARE

内容的提问来源于stack exchange,提问作者JD74

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 07:55:28