ExCiteS/apache-commons-codec-shaded


"Shaded" version of Apache Commons Codec

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.excites:apache-commons-codec-shaded:1.11'
	}
	dependencies {
		implementation("com.github.excites:apache-commons-codec-shaded:1.11")
	}
	<dependency>
	    <groupId>com.github.excites</groupId>
	    <artifactId>apache-commons-codec-shaded</artifactId>
	    <version>1.11</version>
	</dependency>

                            
    libraryDependencies += "com.github.excites" % "apache-commons-codec-shaded" % "1.11"
        
        

                            
    :dependencies [[com.github.excites/apache-commons-codec-shaded "1.11"]]
        
        

Readme


apache-commons-codec-shaded

This is a "shaded" version of Apache Commons Codec for use by Android app developers.

The problem

Android includes an outdated version (v1.3) of commons-codec as an internal library. This library is not exposed in the Android SDK so app developers who want to rely on commons-codec need to treat it as an addition dependency and include it in the APK of their app. However, at runtime Android will always favour its internal version of the library which causes trouble when app code tries to call methods that don't exist in v1.3 but do exist in the version the developer expected to be using.

The solution

Build your Android application with this "shaded" version of the commons-codec, which can be produced by running the gradle build script in this repository. In the resulting jar file the commons-codec package has been renamed from org.apache.commons.codec to shaded.org.apache.commons.codec, thereby avoiding the clash with Android's built-in version of commons-codec.

How does it work?

The build.gradle file fetches the latest version of commons-codec (currently 1.11), applies the package relocation (using johnrengelman's Gradle Shadow plug-in) and installs the resulting jar to the local Maven repository.

How do I use this in my app project?

Hand-built

  • Download or clone this repository
  • Run gradle in the root directory. This will install commons-codec-shaded to your local Maven repository.
  • In the build.gradle file of your own project, add mavenLocal() to the repositories and add compile 'commons-codec:commons-codec-shaded:1.10' to the dependencies.

JitPack

Alternatively you can do all of this in one step by relying on JitPack.io:

  • In your build.gradle file, add maven { url 'https://jitpack.io' } to the list of repositories and add compile 'com.github.ExCiteS:apache-commons-codec-shaded:1.11' to the dependencies.

Credits

By Matthias Stevens for UCL ExCiteS.