adding url to BuildConfig file from Gradle

╄→尐↘猪︶ㄣ 提交于 2019-12-12 20:28:14

问题


My BuildConfig is generated by Gradle. One of my strings is a URL. When I try to create an apk, I get an error about the : in the url. Any ideas what I should tell gradle so this works fine?

Here is what I told Gradle:

buildConfigField "String","My_CLOUD_API","http://12.3.456.789:123"

Here is the BuildConfig.java constant that was created

public static final String My_CLOUD_API = http://12.3.456.789:123;

Here is the error:

error: ';' expected

回答1:


try

buildConfigField "String", "MY_CLOUD_API", '"http://12.3.456.789:123"'



回答2:


Try doing:

buildConfigField "String", "My_CLOUD_API", "\"http://12.3.456.789:123/\""


来源:https://stackoverflow.com/questions/41621823/adding-url-to-buildconfig-file-from-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!