unresolved reference error while generating signed apk in android

Viewed 465

I'm getting an error called "unresolved reference: CUSTOM_BASED_URL" while generating signed apk. but when I'm trying to generate debug apk there is no such type of error

import androidx.databinding.library.BuildConfig
import me.rieshikasharma.india.covid19app.BuildConfig.CUSTOM_BASE_URL
import me.rieshikasharma.india.covid19app.data.retrofit.CustomAppRepository
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.koin.dsl.module
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

val networkModule = module {
    single { provideRetrofit() }
    single { CustomAppRepository(get()) }
}

fun provideRetrofit(): Retrofit {
    return Retrofit.Builder().baseUrl(CUSTOM_BASE_URL).client(provideOkHttpClient())
        .addConverterFactory(GsonConverterFactory.create()).build()
}

fun provideOkHttpClient(): OkHttpClient {
    val builder = OkHttpClient()
        .newBuilder()
    if(BuildConfig.DEBUG){
        val requestInterceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
        builder.addNetworkInterceptor(requestInterceptor)
    }
    return  builder.build()
}

the error has been shown in the above code. the error is "unresolved reference: CUSTOM_BASE_URL please help me to figure it out! thanks

1 Answers

so the url is in the file named buildconfig.java

 package me.rieshikasharma.india.covid19app;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "me.rieshikasharma.india.covid19app.debug";
  public static final String BUILD_TYPE = "debug";
  public static final String FLAVOR = "";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
  // Fields from build type: debug
  public static final String CUSTOM_BASE_URL = "https://api.covid19india.org/";
}

the project is running well in my device(after build apk) but here the problem is that will generating the signed apk it is showing the error "unresolved reference: custom_base_url" also please tell me this that, after I generated build apk..my whole structure of the project got changed also a few new files appeared. and the file in which i saved the URL the whole file is shifted to those folders which are generated by the gradle.

Related