Skip to content

Instantly share code, notes, and snippets.

View robUx4's full-sized avatar

Steve Lhomme robUx4

View GitHub Profile
@robUx4
robUx4 / gist:9362413
Created March 5, 2014 06:54
Copy the Proguard mapping.txt next to the apk with a matching name
android.applicationVariants.all { variant ->
if (variant.buildType.runProguard) {
variant.assemble.doLast {
description "ProGuard mapping copy"
def mappingSource = new File(projectDir, "build/proguard/" + variant.buildType.name+"/mapping.txt")
def mappingDest = new File(variant.outputFile.parent)
copy {
from mappingSource
into mappingDest
@robUx4
robUx4 / gist:9362439
Created March 5, 2014 06:57
Output the APK in a "builds" folder outside of the source tree with specific names between buildtypes and versionCodes
android.applicationVariants.all { variant ->
if (variant.buildType.name == "release") {
variant.outputFile = new File(projectDir.parent + "/builds", archivesBaseName + "-" + versionName + ".apk")
} else if (variant.buildType.name == "kindle") {
variant.outputFile = new File(projectDir.parent + "/builds", "Kindle-" + versionName + ".apk")
} else {
variant.outputFile = new File(projectDir.parent + "/builds", archivesBaseName + "-" + variant.buildType.name + versionCode + ".apk")
}
}
@robUx4
robUx4 / gist:9594891
Created March 17, 2014 06:38
LG Optimus G running 4.1.2
java.lang.IllegalArgumentException: bad parameter
at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:139)
at org.apache.http.client.utils.URLEncodedUtils.parse(URLEncodedUtils.java:76)
at android.webkit.AccessibilityInjector.getAxsUrlParameterValue(AccessibilityInjector.java:404)
at android.webkit.AccessibilityInjector.shouldInjectJavaScript(AccessibilityInjector.java:323)
at android.webkit.AccessibilityInjector.onPageFinished(AccessibilityInjector.java:282)
at android.webkit.WebViewClassic.onPageFinished(WebViewClassic.java:4371)
at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:334)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
@robUx4
robUx4 / gist:9909878
Created April 1, 2014 08:04
Samsung Galaxy S5/S3 running Android 4.4.2
java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1471)
at android.os.Parcel.readException(Parcel.java:1419)
at android.os.storage.IMountService$Stub$Proxy.mkdirs(IMountService.java:769)
at android.app.ContextImpl.ensureDirsExistOrFilter(ContextImpl.java:2627)
at android.app.ContextImpl.getExternalFilesDirs(ContextImpl.java:1197)
at android.app.ContextImpl.getExternalFilesDir(ContextImpl.java:1180)
at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:222)
at com.levelup.touiteur.pictures.levelup.LevelupCache.finishLoadingInMemory(SourceFile:98)
at st.gaw.db.AsynchronousDbHelper$1.handleMessage(SourceFile:98)
@robUx4
robUx4 / ActivityWithAds.java
Last active August 29, 2015 13:58
Block the Play Store from opening unexpectedly (from dubious ad networks)
package com.levelup.touiteur;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Instrumentation;
@robUx4
robUx4 / gist:10017997
Created April 7, 2014 10:34
Log.wtf() to be used only for unrecoverable states, as it seems in 4.4 there's a WtfHandler that can be set and might throw an Exception
android.util.Log$TerribleFailure: popping a database work that never started for m{42fbb7f0 olof_k} type:1
at android.util.Log.wtf(Log.java:290)
at android.util.Log.wtf(Log.java:256)
at com.levelup.logutils.FLog.wtf(SourceFile:152)
at com.levelup.logutils.FLogger.wtf(SourceFile:79)
at com.levelup.touiteur.c.a.wtf(SourceFile:133)
at com.levelup.touiteur.c.d.c(SourceFile:80)
at com.levelup.touiteur.stream.a.c(SourceFile:226)
at com.levelup.touiteur.stream.a.b.b(SourceFile:249)
at com.levelup.touiteur.stream.a.d.a(SourceFile:211)
@robUx4
robUx4 / tighter call
Last active August 29, 2015 13:59
Application.onCreate double call
0 | 00:00:00:040 | I/Plume_55902 Plume Oncreate
1 | 00:00:00:040 | I/Plume_55902 Startup: loggers logger:com.levelup.touiteur.c.c@41c209c8
2 | 00:00:00:125 | D/Plume_55902 clear PhotoCache memory
3 | 00:00:00:203 | D/Plume_55902 clear PhotoCache memory
4 | 00:00:00:988 | D/PlumeStream Start stream checker
5 | 00:00:01:017 | D/PlumeStream assertRunningStreams needs stream:true
6 | 00:00:01:017 | D/PlumeStream assertRunningStream mWantsStreamRunning:true
7 | 00:00:01:063 | D/PlumeStream run user streams needed:true instance:null
8 | 00:00:01:063 | I/PlumeStream attach b{41c5d400 connected:false} state was:OFFLINE
9 | 00:00:01:066 | D/PlumeStream m{41c42c38 kraatsie66} startListening isStreamStarted:false connected:false
@robUx4
robUx4 / gist:4a8a6f15c4e7d96021e3
Created July 8, 2014 13:33
Android InetSocketAddress source
/**
* Returns the hostname if known, or the result of {@code InetAddress.getHostAddress}.
* Unlike {@link #getHostName}, this method will never cause a DNS lookup.
* @since 1.7
* @hide 1.7 - remember to add a link in the getHostName documentation!
*/
public final String getHostString() {
return (hostname != null) ? hostname : addr.getHostAddress();
}
@robUx4
robUx4 / settings.gradle
Created July 8, 2014 18:59
FileLogger gradle
// version 1
include ':dependencies:Android-FileLogger:library'
// version 2
include 'FileLogger'
project(':FileLogger').projectDir = new File('dependencies/Android-FileLogger/library')
@robUx4
robUx4 / project.gradle
Created September 1, 2014 07:39
Android-Switch workaround
dependencies {
def artifactAndroidSwitch = 'org.jraf:android-switch-backport:1.3.+'
def useLocalAndroidSwitch = false
def localAndroidSwitch = ':android-Switch'
allprojects {
rootProject.allprojects.project.each {
if (it.path == localAndroidSwitch) {