sdk_path = "/path/to/android-sdk-linux_86"
ndk_path = "/path/to/android-ndk-r8e"
+# Build tools version to be used
+build_tools = "18.0.1"
+
# May be necessary for fdroid update; you may still need to make a symlink to
# aapt in platform-tools
aapt_path = "/path/to/android-sdk-linux_x86/build-tools/17.0.0/aapt"
#Command for running maven 3 (could be mvn, mvn3, or a full path)
mvn3 = "mvn3"
+# Gradle command
+gradle = "gradle"
+
+# Android gradle plugin version
+gradle_plugin = "0.5.+"
+
repo_url = "https://f-droid.org/repo"
repo_name = "F-Droid"
repo_icon = "fdroid-icon.png"
vcs.gotorevision(None)
+ flavour = None
if len(app['builds']) > 0:
if 'subdir' in app['builds'][-1]:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
+ if 'gradle' in app['builds'][-1]:
+ flavour = app['builds'][-1]['gradle']
hver = None
hcode = "0"
vcs.gotorevision(tag)
# Only process tags where the manifest exists...
- path = common.manifest_path(build_dir)
- print "Trying manifest at %s" % path
- if os.path.exists(path):
- version, vercode, package = common.parse_androidmanifest(build_dir)
+ path = common.manifest_path(build_dir, flavour, gradle,
+ build_tools, gradle_plugin)
+ if path is not None and os.path.exists(path):
+ version, vercode, package = common.parse_androidmanifest(path)
print "Manifest exists. Found version %s" % version
if package and package == app['id'] and version and vercode:
if int(vercode) > int(hcode):
if len(app['builds']) > 0:
if 'subdir' in app['builds'][-1]:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
+ if 'gradle' in app['builds'][-1]:
+ flavour = app['builds'][-1]['gradle']
if not os.path.isdir(build_dir):
return (None, "Subdir '" + app['builds'][-1]['subdir'] + "'is not a valid directory")
- version, vercode, package = common.parse_androidmanifest(build_dir)
+ path = common.manifest_path(build_dir, flavour, gradle, build_tools,
+ gradle_plugin)
+ if path is None:
+ return (None, "Gradle flavour not found")
+
+ version, vercode, package = common.parse_androidmanifest(path)
if not package:
return (None, "Couldn't find package ID")
if package != app['id']:
def main():
#Read configuration...
+ globals()['gradle'] = "gradle"
execfile('config.py', globals())
# Parse command line...
if 'subdir' in app['builds'][-1]:
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
- new_name = common.fetch_real_name(app_dir)
- if new_name != app['Auto Name']:
- app['Auto Name'] = new_name
- if not writeit:
- writeit = True
+ #new_name = common.fetch_real_name(app_dir)
+ #if new_name != app['Auto Name']:
+ #app['Auto Name'] = new_name
+ #if not writeit:
+ #writeit = True
except Exception:
msg = "Auto Name failed for %s due to exception: %s" % (app['id'], traceback.format_exc())
import time
import operator
import cgi
+import fileinput
def getvcs(vcstype, remote, local, sdk_path):
if vcstype == 'git':
return ''
# Find the AM.xml - try the new gradle method first.
-def manifest_path(app_dir):
- gradlepath = os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml')
- if os.path.exists(gradlepath):
- return gradlepath
- rootpath = os.path.join(app_dir, 'AndroidManifest.xml')
- return rootpath
+def manifest_path(app_dir, flavour, gradle, build_tools, gradle_plugin):
+
+ if flavour is None:
+ return os.path.join(app_dir, 'AndroidManifest.xml')
+
+ if not os.path.exists(os.path.join(app_dir, 'src', flavour)):
+ return None
+
+ for line in fileinput.input(os.path.join(app_dir, 'build.gradle'), inplace=True):
+ if 'buildToolsVersion' in line:
+ print 'buildToolsVersion "%s"' % build_tools,
+ elif 'com.android.tools.build:gradle:' in line:
+ print "classpath 'com.android.tools.build:gradle:%s'" % gradle_plugin,
+ else:
+ print line,
+
+ subprocess.Popen([gradle, 'process'+flavour+'ReleaseManifest'], cwd=app_dir).communicate()
+
+ return os.path.join(app_dir, 'build', 'manifests', flavour, 'release', 'AndroidManifest.xml')
# Retrieve the package name
# Extract some information from the AndroidManifest.xml at the given path.
# Returns (version, vercode, package), any or all of which might be None.
# All values returned are strings.
-def parse_androidmanifest(app_dir):
+def parse_androidmanifest(manifest):
vcsearch = re.compile(r'.*android:versionCode="([0-9]+?)".*').search
vnsearch = re.compile(r'.*android:versionName="([^"]+?)".*').search
version = None
vercode = None
package = None
- for line in file(manifest_path(app_dir)):
+ for line in file(manifest):
if not package:
matches = psearch(line)
if matches:
matches = vcsearch(line)
if matches:
vercode = matches.group(1)
- if version.startswith('@string/'):
- version = retrieve_string(app_dir, version[8:])
+ #if version.startswith('@string/'):
+ #version = retrieve_string(app_dir, version[8:])
return (version, vercode, package)
class BuildException(Exception):