[英]unresolved reference error while generating signed apk in android
I'm getting an error called "unresolved reference: CUSTOM_BASED_URL" while generating signed apk.在生成签名的 apk 时,我收到一个名为“未解析的参考:CUSTOM_BASED_URL”的错误。 but when I'm trying to generate debug apk there is no such type of error但是当我尝试生成调试 apk 时没有这种类型的错误
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错误是“未解决的参考:CUSTOM_BASE_URL 请帮我弄清楚!谢谢
so the url is in the file named buildconfig.java所以 url 在名为 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.该项目在我的设备中运行良好(在构建 apk 之后)但这里的问题是将生成签名的 apk 它显示错误“未解决的参考:custom_base_url”也请告诉我,在我生成构建 apk ..my 之后项目的整个结构发生了变化,也出现了一些新文件。 and the file in which i saved the URL the whole file is shifted to those folders which are generated by the gradle.以及我保存 URL 的文件,整个文件被转移到由 gradle 生成的文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.