I'm working on an online course and i had these lines of code:
String baseUrl = "http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7";
String apiKey = "&APPID=" + BuildConfig.OPEN_WEATHER_MAP_API_KEY;
URL url = new URL(baseUrl.concat(apiKey));
So, the API key apparently had to be set up on the BuildConfig.java file.
I tried to do that, by adding this line of code to the BuildConfig.java file:
public static final String OPEN_WEATHER_MAP_API_KEY = 111111111111111111;
The first issue is that the string was saved without quotation marks and wouldn't let me compile.
The second, and main issue is that i can't modify that file anymore. Every time i delete the line or add those missing quotation marks, and then try to compile, the line reverts to it's flawed version and compilation stops.
I also get this message when i try to modify BuildConfig.java : "Generated source files should not be edited. The changes will be lost when sources are generated."
Any help will be welcome.
Values in BuildConfig
come from the build system. Custom BuildConfig
values like OPEN_WEATHER_MAP_API_KEY
come from buildConfigField
statements in your build.gradle
file. The BuildConfig.java
file is off of your build/
directory; files in there are generated by the build process and cannot be modified by hand. Instead, examine your build.gradle
files and find where your API key is defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With