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
You don`t have to replace \platforms\android-21\android.jar.
It destroy the SDK and you may not submit those changes onto git.
Below way may be more easier:
See How do I build the Android SDK with hidden and internal APIs available? and get framework_all.jar
Put framework_all.jar in system_libraries besides app in your projects.
change app/build.gradle like
dependencies {
compile fileTree(dir: 'libs', include: ['.jar'])
provided fileTree(dir: '../system_libraries', include: ['.jar'])
}
AS will gives a tips like "Gradle files have changed since .... Sync Now", click Sync Now.
Goto Project view and you will see platform_all.jar in External Libraries.
Each time you changed any .jar under system_libraries, you need to do some change in app/build.gradle and re-sync it.