simplify versionCode

removed implementation was some Eclipse/ant style, now it's Gradle style
This commit is contained in:
Hannes Achleitner 2019-01-27 10:55:08 +01:00
parent 0474717ba1
commit 8e5abeea3a
3 changed files with 9 additions and 27 deletions

View File

@ -18,20 +18,6 @@ buildscript {
} }
} }
def getMyVersionName() {
def parsedManifestXml = (new XmlSlurper())
.parse("${projectDir}/src/main/AndroidManifest.xml")
.declareNamespace(android: "http://schemas.android.com/apk/res/android")
return parsedManifestXml."@android:versionName"
}
def getMyVersionCode() {
def parsedManifestXml = (new XmlSlurper())
.parse("${projectDir}/src/main/AndroidManifest.xml")
.declareNamespace(android: "http://schemas.android.com/apk/res/android")
return parsedManifestXml."@android:versionCode".toInteger()
}
android { android {
compileSdkVersion rootProject.ext.compileSdkVersion compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion buildToolsVersion rootProject.ext.buildToolsVersion
@ -40,8 +26,12 @@ android {
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true multiDexEnabled true
versionCode getMyVersionCode() // Version code schema:
versionName "${getMyVersionName()}" // "1.2.3-SNAPSHOT" -> 1020300
// "1.2.3-RC4" -> 1020304
// btw I would recommend to autogenerate this
versionCode 1070195
versionName "1.7.1"
testApplicationId "de.test.antennapod" testApplicationId "de.test.antennapod"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
generatedDensities = [] generatedDensities = []

View File

@ -1,14 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.danoeh.antennapod" package="de.danoeh.antennapod"
android:installLocation="auto" android:installLocation="auto">
android:versionCode="1070195"
android:versionName="1.7.1">
<!--
Version code schema:
"1.2.3-SNAPSHOT" -> 1020300
"1.2.3-RC4" -> 1020304
-->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="android.permission.WAKE_LOCK"/>

View File

@ -1,10 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
repositories { repositories {
google()
jcenter() jcenter()
mavenCentral() mavenCentral()
google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.android.tools.build:gradle:3.1.0'