Error message:
D:\002_Project\002_Android_Learn\ClassLoader_Demo\app\build\generated\source\buildConfig\debug\com\example\classloader_demo\BuildConfig.java:15: Error: Symbol not found
public static final String market = GooglePlay;
^
Symbol: Variable GooglePlay
Location: Class BuildConfig
In the gradle.properties configuration file in the root of the Android Studio project, configure as:
# Configure whether to be on Google Play
isGooglePlay=true
# Configure the current app marketplace
market=GooglePlay
The corresponding configuration in build.gradle is as follows :
android {
defaultConfig {
// Whether the app is available on Google Play
buildConfigField("boolean", "isGooglePlay", isGooglePlay)
// The current app marketplace
buildConfigField("String", "market", market)
}
}
The generated BuildConfig.java configuration is as follows :
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.example.classloader_demo;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.example.classloader_demo";
public static final String BUILD_TYPE = "debug";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
// Field from default config.
public static final boolean isGooglePlay = true;
// Field from default config.
public static final String market = GooglePlay;
}
The last googleplay string has no double quotation marks, resulting in an error;
2. Solution
use
buildConfigField("String", "market", "\"${market}\"")
Groovy code , you can generate the following configuration in BuildConfig.java :
public static final String market = "GooglePlay";
The double quotes in the string need to be added with their own escape characters, otherwise they are invalid;
The first level of double quotes in “\”${market}\”” is because the buildConfigField function requires three string variables to be passed in, and the third parameter must be a string;
The second double-quote \” \”” uses the transfer character, which is the double-quote displayed in BuildConfig, and the internal ${market} is the GooglePlay configuration content ;
Read More:
- [Solved] Android gradle Error: gradle project sync failed. Please fix your project and try again
- Gradle location is incorrect in IntelliJ
- Error in Cordova project execution command after Android studio upgrade: could not find gradle wrapper within Android SDK
- Android Studio sync build.gradle appears: Failed to resolve: com.android.support:appcompat problem
- Could not install Gradle distribution from ‘https://services.gradle.org/distributions/gradle-6.7.1-b
- Viewing Android dependency tree using gradle
- Gradle tasks disappeared after upgrading Android stuido 4.2?
- Common forms of springboot2. X boot class location
- How to Fix Android Error:This Gradle plugin requires Studio 3.0 minimum
- Record once the solution of gradle dependency problem: failed to determine a suitable driver class
- Android studio “sync project with gradle files” button disappears
- android studio:Error inflating class android.support.v4.widget.SwipeRefreshLayout
- Error inflating class in WebView in Android 5. X android.webkit.WebView Solutions
- Error: (21,13) Java: symbol not found: class order location: interface mapper.ordermapper
- [actual record of Android stepping on the pit] Android studio reports an error invalid gradle JDK configuration found after importing the project
- android studio Error Gradle project sync failed. Please fix your project and try again
- Android error reporting: error inflating class android.webkit.WebView
- Import Android project Error:Internal error : org.gradle.tooling .BuildException: Could not execute build…
- Listview remembers location not itme location
- As Error:Could not determine the class-path for interface com.android.builder.model.AndroidProject.