One Modify version and specify build apk filename "optional"
Switch items to Project View, open the build.gradle file in the app directory
1.1 RepairFixed softwareversion
Versioncode is the large version number of the app , which is the value type, default to 1 I change this to 2 .
Versionname is The specific version number of the app, for the inter-string type, the default is 1.0 I changed it here 2.0
1.2 Specifies the generated APK file name
is modified in the Build.gradle file, the default generated release version of the apk is named app-release.apk.
inside Android defaultconfig add content under the same layer (outputfilename change to the desired apk name)
Android.applicationVariants.all {
Variant-
Variant.outputs.all {
the generated apk file name is specified here
OutputFileName = "sectest.apk"
}
}
TwoEnable code obfuscation "optional"2.1 Enabling code obfuscation
is also in the build.gradle buildtypes/release/minifyenabled true false )
proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro ' Specify the obfuscation rules to use where Proguard-android.txt Yes android default obfuscation rules (in $SDK _path , tools\proguard proguard-rules.pro proguard-rules.pro build.gradle file in the same sibling directory).
I only use the system default obfuscation rules here, so Proguard-rules.pro does not need to be modified either.
2.2 Verification CodeSuccessconfusing
After the APK is last generated , use tools such as Apkide to decompile the apk , You can see that the custom variable names and function names have been replaced with meaningless strings.
third, export the signature release versionapk
menu Bar ----Build----Generate signed APK
in the In the key store path, enter the location of the key file that you want to use for signing, and enter the read and write username password for the key file (if you do not have the key file click "Create New" in the diagram)
APK Destination Folder-----apk file generated directory
Build Type---- generate release version or debug version
Signature Version---- which parts are signed
After the build is complete, a release folder under the specified build directory will find the generated apk(app-release.apk Is the version I generated earlier)
Android Studio Package Generation APK Tutorial