I have successfully extracted the class files from an android emulator and replaced them into my android.jar file residing inside my \\platforms\\android-21\\android.jar and
Here's an alternative that does not require building the entire android SDK JAR or modifying your android SDK at all. If you have a JAR with some of the @hide
android SDK classes and/or methods in it you can add this hunk to your standard android project build.gradle file:
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xbootclasspath/p:.jar"
}
}
}
This will prepend your JAR to the bootclasspath which has the android.jar from the selected SDK in it. The java compiler will prefer to use classes in the prepended bootclasspath when compiling thus overriding the android.jar from the SDK.
See http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html
The drawback is that IntelliJ/Android Studio doesn't seem to understand this at the higher level so methods appear red in the editor but the build works fine. You can actually combine this with the provided
solution to at least get additional classes to show up as valid in the editor but exposed @hide
methods are still unknown to the IDE.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'], 'exclude': ['.jar'])
provided files('libs/.jar')
}
I haven't played with it long enough to find how to reference the relative path in the compilerArgs but it should be easy enough.