Cordova 编译时如何设定CompileSdkVersion

Setting Gradle Properties

It is possible to configure the Gradle build by setting the values of certain Gradle properties that Cordova exposes. The following properties are available to be set:

Property Description
cdvBuildMultipleApks If this is set, then multiple APK files will be generated: One per native platform supported by library projects (x86, ARM, etc). This can be important if your project uses large native libraries, which can drastically increase the size of the generated APK. If not set, then a single APK will be generated which can be used on all devices
cdvVersionCode Overrides the versionCode set in AndroidManifest.xml
cdvReleaseSigningPropertiesFile Default: release-signing.properties
Path to a .properties file that contains signing information for release builds (see Signing an App)
cdvDebugSigningPropertiesFile Default: debug-signing.properties
Path to a .properties file that contains signing information for debug builds (see Signing an App). Useful when you need to share a signing key with other developers
cdvMinSdkVersion Overrides the value of minSdkVersion set in AndroidManifest.xml. Useful when creating multiple APKs based on SDK version
cdvBuildToolsVersion Overrides the automatically detected android.buildToolsVersion value
cdvCompileSdkVersion Overrides the automatically detected android.compileSdkVersion value

You can set these properties in one of four ways:

  1. By setting environment variables like so:

      $ export ORG_GRADLE_PROJECT_cdvMinSdkVersion=20
      $ cordova build android
    
    
  2. By using the --gradleArg flag in your Cordova build or run commands:

      $ cordova run android -- --gradleArg=-PcdvMinSdkVersion=20
    
    
  3. By placing a file called gradle.properties in your Android platform folder (/platforms/android) and setting the properties in it like so:

      # In /platforms/android/app/gradle.properties
      cdvMinSdkVersion=20
    
    
  4. By extending build.gradle via a build-extras.gradle file and setting the property like so:

      // In /platforms/android/app/build-extras.gradle
      ext.cdvMinSdkVersion = 20
    

参考

cordova 官方说明

你可能感兴趣的:(Cordova 编译时如何设定CompileSdkVersion)