I am following a lesson on Android App development but still unable as to how to use the TMDB_API_KEY and used in: api.getTopRatedMovies(BuildConfig.TMDB_API_KEY, LANGUAGE, page).enqueue(call);
. I tried creating class level variable public static final String TMDB_API_KEY = "xxxxxxxxxxx";
in public class MoviesRepository
but it did not work. I also tried adding it in gradle.properties but no success.
I added following inside buildTypes in build.gradle(App) file: debug { buildConfigField 'String', "TMDB_API_KEY", "xxxxxxxxxx" }
But now I am getting another error:
error: cannot find symbol private static MoviesRepository repository; ^ symbol: variable xxxxxxxxxxxxx
Note xxx is api key. What I am doing wrong?
EDIT: I was not escaping quotes, now following solved the issue:
debug { buildConfigField 'String', "TMDB_API_KEY", "\"xxxxxxxxxxxxxx\"" }