找不到属性'VERSION_CODE'错误:(21,0)
我想在Android Studio 1.5.1中导入一个项目。我首先删除了找不到'com.android.application'的错误,但是这个错误已经上升了。 enter image description here找不到属性'VERSION_CODE'错误:(21,0)
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}"
}
你是如何定义VERSION_CODE变量? –