2

我已在 DevEcoStudio 中将 HarmonyOS SDK 从 5 升级到 6。我只在“文件 -> 设置 -> 外观和行为 -> 系统设置 -> HarmonyOS SDK”下看到 SDK6

在此处输入图像描述

现在,当我尝试使用 SDK 5 打开一个项目时,DevEco 会问我以下问题 - 在此处输入图像描述

选择“使用 DevEco 的 HarmonyOS SDK”后,它显示了以下内容 - 在此处输入图像描述

因此,最后在设置 SDK 之后,当我尝试“打开”现有项目时 - 我看到以下错误。

Unable to download the HarmonyOS SDK. Unable to install java:2.1.1.21 as the license has not been accepted. Use the 'File -> Settings -> Appearance & Behavior -> System Settings -> HarmonyOS SDK' to agree to the license agreement and download.

IDE 中的日志如下所示 - 在此处输入图像描述

我们如何解决这个问题并成功打开项目?

DevEcoStudio and SDK Version Info: 

DevEco Studio 2.1 Release //Still Old Version of DevEcoStudio
Build Version: 2.1.0.501, built on June 2, 2021
Runtime version: 11.0.9+11-b944.49 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
open-source software
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1484M
Cores: 8
Registry: external.system.auto.import.disabled=true

SDK Version: 6 //latest received Offline```
4

1 回答 1

0

所以,为了在 SDK 升级后成功编译项目是——

打开项目级别和模块级别的build.gradle 并将 compileSdkVersion更改为最新版本。

compileSdkVersion 6 // Target SDK version for building your app.
    defaultConfig {
        compatibleSdkVersion 5 //Earliest SDK version compatible with your app.
}

您可以查看Build Config以获得更多 HarmoyOS 项目配置。

于 2021-12-03T08:37:54.873 回答