Build Android Studio app via command line

后端 未结 12 1789
梦谈多话
梦谈多话 2020-11-27 10:36

I want to build an Android Studio app (the Gradle build system), but I want to do this via the command line.

12条回答
  •  天命终不由人
    2020-11-27 11:25

    there are two build types to build your application using the Gradle build settings: one for debugging your application — debug — and one for building your final package for release — release mode.

    Building in Debug Mode

    • First Navigate to Android studio project Root folder using CMD

    • run this command gradlew.bat assembleDebug

    • Output window look like this

    Build signed apk in Release Mode

    • Edit the build.gradle file to build your project in release mode:

      android {
      ...
      defaultConfig { ... }
      signingConfigs {
          release {
              storeFile file("myreleasekey.keystore")
              storePassword "password"
              keyAlias "MyReleaseKey"
              keyPassword "password"
          }
      }
      buildTypes {
          release {
              ...
              signingConfig signingConfigs.release
          }
      }}
      

    • run this command gradlew.bat assembleRelease

    Done.Good Luck!

提交回复
热议问题