Automation for Android release build

后端 未结 5 1304
醉梦人生
醉梦人生 2021-01-31 04:43

I have ten Android projects in one folder. For each project, I can use ant debug to build it. So it is no problem to write a simple script to compile all these proj

5条回答
  •  余生分开走
    2021-01-31 04:53

    Gradle-based builds

    1) Create a secure.properties file to contain your passwords:

    key.store.password=
    key.alias.password=
    

    You probably don't want it under version control, which is why we're putting the passwords in a separate *.properties file. If you don't mind having your passwords under version control, you can enter your passwords directly into build.gradle, but that's not recommended, so I'm not directly showing that.

    2) Set up your build.gradle as follows:

    Properties secureProperties = new Properties()
    secureProperties.load(new FileInputStream("secure.properties"))
    
    android {
        signingConfigs {
            release {
                storeFile file("")
                storePassword secureProperties['key.store.password']
                keyAlias ""
                keyPassword secureProperties['key.alias.password']
            }
        }
    
        buildTypes {
            release {
                signingConfig signingConfigs.release
            }
        }
    }
    

    And that's it. ./gradlew assembleRelease now builds and signs my APK without prompting for my password.

    Ant-based builds

    1) Create a secure.properties file to contain your passwords:

    key.store.password=
    key.alias.password=
    

    You probably don't want it under version control, which is why we're not putting the passwords in one of the existing *.properties files. If you don't mind having your passwords under version control, put these two lines in ant.properties and you're done.

    2) Create a custom_rules.xml file to tell the build system about your secure.properties file.

    
    
      
    
    

    I'm not familiar with this build system, so I'm not sure about the project element's name or default properties, but I believe what I chose should work for everybody.

    2b) Any recent version of the Android SDK tools should be good to go, but if for some reason your build.xml file doesn't contain the following, you should add it:

    
    

    And that should be it. ant release now builds and signs my APK without prompting for my password.

提交回复
热议问题