Development record of developer who study hard everyday.

,

How to solve error: constant expression required

 How to solve error: constant expression required


After I upgrade Gradle version upto 8.0, I encounter "constant expression required" error.

This is because AGP 8.0 doesn't allow reference to resourceID.

In my case, I use below code:

switch(view.id) {

    case sample1: 

    case sample2:

    ......

}


Solution1:

Change switch statement to if-else statement


Solution2:

Add below properties to gradle.properties file

android.nonFinalResIds = false






















Share:
Location: 미국 뉴욕

댓글 없음:

댓글 쓰기