今天gradle代码中需要用到gradle.properties自定义的字符串类型字段,用以判断构建逻辑行为;
因为直接用${}访问等到的类型是object类型,无法和String类型进行直接比较;会报错
String msg = ${BUILD_KEY}
String msg = ${BUILD_KEY} + ""
A problem occurred evaluating root project 'abc'.
> Could not find method $() for arguments [build_6agd6j0y7tmg9nybw2ocuza0m$_run_closure1$_closure4$_closure18@71aaa5e3] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
只要写成下面的形式就可以了
String msg = "${BUILD_KEY}"
来作个笔记
版权声明:本文为chuyouyinghe原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。