android - 在android中生成签名apk时 Unresolved reference 错误

标签 android reference apk signed

在生成签名的 apk 时,我收到一个名为“未解析的引用:CUSTOM_BASED_URL”的错误。
但是当我尝试生成调试 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()
}

错误已显示在上面的代码中。错误是“ Unresolved reference :CUSTOM_BASE_URL
请帮我弄清楚!
谢谢

最佳答案

所以 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/";
}

该项目在我的设备中运行良好(在构建 apk 之后)但这里的问题是生成签名的 apk 它显示错误“ Unresolved reference :custom_base_url”
也请告诉我,在我生成构建 apk 之后,我的整个项目结构发生了变化,也出现了一些新文件。
以及我保存 URL 的文件,整个文件被转移到 gradle 生成的那些文件夹中。

关于android - 在android中生成签名apk时 Unresolved reference 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62157603/

相关文章:

android - 签署Android apk?

Android重复警报,每次打开时都会覆盖 self

python - 在没有exec/eval,python的字符串中调用代码

android - 从 APK 安装应用程序时出现 java.lang.ClassNotFoundException

Excel公式查找其他单元格使用的引用

.net - 为什么 Visual Studio 2012 不记得我的 'Copy Local' 首选项?

android - 如何在没有 android studio 的情况下签署 android apk

android - 单击 MediaRouteButton 后的样式对话框

android - 使用 Dagger 2 的 Activity 场注入(inject)

android - 如何检测android中的翻转 Action ?