DevEcoStudio: Error after upgrading from SDK 5 to SDK6

166 Views Asked by At

I have upgraded HarmonyOS SDK from 5 to 6 in DevEcoStudio. I see SDK6 only under 'File -> Settings -> Appearance & Behavior -> System Settings -> HarmonyOS SDK'

enter image description here

Now, when I try to open a project with SDK 5, DevEco asks me the following - enter image description here

After selecting "Use DevEco's HarmonyOS SDK", it shows me the following - enter image description here

So, finally after setting up the SDK, when I am trying to "Open" an existing project - I see the following error.

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.

Logs in the IDE looks like this - enter image description here

How can we fix this and open the project successfully?

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```
1

There are 1 best solutions below

0
On

So, In order to compile the project successfully after the SDK upgrade is -

Open build.gradle of your Project level and Module level both and change the compileSdkVersion to the latest.

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

You can check Build Config for more HarmoyOS Project configurations.