Skip to content

Instantly share code, notes, and snippets.

@jordanbeck
jordanbeck / README.md
Last active December 31, 2015 01:38
Attempting to update versionName and versionCode for gradle buildTypes [and currently failing]

This currently does not work the way I want, but I want to document it for personal reference.

Scenario:

I have an app that uses a library project being build in parallel. I want to have three different build types: debug, internal, release. I want each of those to have it's own package name, app name, version number, and version code. I want to be able to at least automate a build for internal on a nightly basis and upload to HockeyApp.

Problems:

  • First problem I ran into was that buildTypes in gradle do not allow you to specify versionNumber or versionCode. Just suffixes for those properties. So I moved to flavors...
  • Unfortunately, I'm using BuildConfig and with flavors, BuildConfig.java is not found by Android Studios. Everything does work this way (I can run gradle commands from the command line just fine), but without my IDE, it's kind of hard to work. Also, a downside to this approach is that it produces too many apks. If I have the three desired build types and have to have three flavors,
@Tagakov
Tagakov / DevButton.java
Last active July 30, 2016 09:49
Hidden button for debugging purposes. Should be used with: debugCompile 'com.squareup:seismic:1.0.2'
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@hayeshaugen
hayeshaugen / gist:994453
Created May 27, 2011 01:07
Android SDK headless install for Linux Jenkins CI
# sudo su -
# apt-get install openjdk-6-jdk
# apt-get install ant1.8
Source control, in this case svn:
# apt-get install subversion
Install Jenkins
@lmacken
lmacken / linkify.py
Created February 21, 2012 19:04
linkify.py - Turns URLs into links
#!/usr/bin/env python
# linkify.py - Turns URLs into links.
#
# Using on a file:
#
# $ linkify.py <filename>
# <a href="http://lewk.org">http://lewk.org</a>
#
# Using within a pipeline:
#
@rpavlik
rpavlik / add-package-from-testing
Created October 21, 2013 17:08
Selectively adding packages from Debian Testing
#!/bin/bash
RELEASE=testing
PREFS=/etc/apt/preferences.d/debian-${RELEASE}
PRIORITY=300
# Set up two variables: one with the package names, and one with package
# names followed by /testing (for example)
PACKAGENAMES="$@"
for pkg in "$@"; do
@felipecsl
felipecsl / ExceptionParser.java
Last active January 28, 2019 12:42
Helper class to parse error response body on Retrofit 2
public static class ExceptionParser {
private final ResponseBody body;
private final String bodyString;
private final Converter.Factory converterFactory;
public ExceptionParser(Response response, Converter.Factory converterFactory) {
this.converterFactory = converterFactory;
this.body = cloneResponseBody(response.errorBody());
this.bodyString = getBodyAsString(body);
}
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Build.VERSION;
public class AlarmManagerCompat {
private final AlarmManager mAlarmManager;
public AlarmManagerCompat(Context context) {
@Tagakov
Tagakov / Di.kt
Last active January 16, 2020 15:15
template for adding new controller to DI graph
typealias YourController = ListEditorController
//do not forget to rename component and module
//do not forget to add module to parent component
//do not forget to add HasControllerInjector to parent entity [Application, Activity, Controller] if not present
@Subcomponent(modules = [ComponentModule::class])
interface RenameMeComponent : AndroidInjector<YourController> {
@Subcomponent.Builder
abstract class Builder : AndroidInjector.Builder<YourController>()
@gortok
gortok / pre-receive.py
Last active June 8, 2020 12:39
Python Pre Receive hook for checking commit messages
#!/bin/python
import sys
import re
import subprocess
#Format: "oldref newref branch"
line = sys.stdin.read()
(base, commit, ref) = line.strip().split()
new_branch_push = re.match(r'[^1-9]+', base)