0

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\"" }
Crunch
  • 57
  • 12
  • https://developer.android.com/studio/build/gradle-tips#share-custom-fields-and-resource-values-with-your-app-code – CommonsWare Apr 15 '20 at 21:07
  • check this link https://stackoverflow.com/q/30796533/3497972 – akashzincle Apr 15 '20 at 21:09
  • Thanks all, I was not escaping quotes, now following solved the issue: debug { buildConfigField 'String', "TMDB_API_KEY", "\"xxxxxxxxxxxxxx\"" } – Crunch Apr 15 '20 at 22:20

0 Answers0