我正在尝试在Android Studio 1.5.1中导入项目。我首先删除了一个未找到的“com.android.application”错误,但随后出现了此错误。
enter image description here
Gradle sync failed: Could not find property 'VERSION_CODE' on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=14, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=23, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.fractalwrench.androidbootstrap.sample, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}}.
最佳答案
问题出在VERSION_CODE和VERSION_NAME。我猜他们在您的项目中丢失了。您可以像这样对版本代码和版本名称进行硬编码-
versionCode 21
versionName "1.0"
或可以像这样使其动态-
def versionMajor = 1
def versionMinor = 1
def versionBuild = 0
defaultConfig {
versionCode versionMajor * 1000000 + versionMinor * 10000 + versionBuild * 100
versionName "${versionMajor}.${versionMinor}.${versionBuild}"
}
关于android - 找不到属性 'VERSION_CODE'错误:(21,0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36781052/