简体   繁体   中英

Maven android plugin error “constant expression required”

I am writing maven build scripts for my project which has dependency to another android project as apklib . When I execute

mvn clean install

goal generate-sources executes successfully. But, R.java generated for apklib project contains non-constant variables ie public static int . So, that causes error

constant expression required

during compile time. My question is can I change default maven android plugin behaviour that passes argument --non-constant-id to aapt tool. Or you can suggest any other solution as well.

Details of build configuration:

Android plugin version: 3.6.0 Platform: 8 Platform version: 2.2.1

The error is causing, because resource ids are used inside switch case. And switch case requires constants. So, I am changing switch cases inside my APKLIB project to if-else statements. Please suggest if any other solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM