简体   繁体   English

我无法打开班级,只是找到一个BuildConfig文件

[英]I can't open my class just find a BuildConfig file

For unknown reason a java file in an android studio project has a sub arrow to BuildConfig class from an other package of an other project 出于未知原因,android studio项目中的java文件具有从另一个项目的另一个包到BuildConfig类的子箭头

/**
 * Automatically generated file. DO NOT MODIFY
 */
package alsayed.aly.maintenanceplaner;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "alsayed.aly.maintenanceplaner";
  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";
}


I tried to revert it but it is not working as the file just created now. 我试图还原它,但是由于现在刚刚创建的文件,它无法正常工作。

At build time, Gradle generates the BuildConfig class so your app code can inspect information about the current build. 在构建时,Gradle会生成BuildConfig类,因此您的应用代码可以检查有关当前构建的信息。

You can also add custom fields to the BuildConfig class from your Gradle build configuration file using the buildConfigField() method and access those values in your app's runtime code. 您还可以使用buildConfigField()方法将自定义字段从Gradle构建配置文件添加到BuildConfig类,并在应用程序的运行时代码中访问这些值。 Likewise, you can add app resource values with resValue(). 同样,您可以使用resValue()添加应用程序资源值。

 android {
  ...
  buildTypes {
    release {
      // These values are defined only for the release build, which
      // is typically used for full builds and continuous builds.
      buildConfigField("String", "BUILD_TIME", "\"${minutesSinceEpoch}\"")
      resValue("string", "build_time", "${minutesSinceEpoch}")
      ...
    }
    debug {
      // Use static values for incremental builds to ensure that
      // resource files and BuildConfig aren't rebuilt with each run.
      // If they were dynamic, they would prevent certain benefits of
      // Instant Run as well as Gradle UP-TO-DATE checks.
      buildConfigField("String", "BUILD_TIME", "\"0\"")
      resValue("string", "build_time", "0")
    }
  }
}

In your app code, you can access the properties as follows: 在您的应用程序代码中,您可以按以下方式访问属性:

Log.i(TAG, BuildConfig.BUILD_TIME);
Log.i(TAG, getString(R.string.build_time));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM