Search code examples
javaandroidbyte-buddy

Error: ByteBuddyAgent for ByteBuddy


Unable to install ByteBuddyAgent in android

code in build.gradle

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'net.bytebuddy:byte-buddy:1.4.18'
    compile 'net.bytebuddy:byte-buddy-android:1.4.18'
    compile 'net.bytebuddy:byte-buddy-agent:1.4.18'

code to install ByteBuddyAgent

ByteBuddyAgent.install();

This is the compilation error, since java.lang don't have instrument and management packages.

Error:(31, 35) error: cannot access Instrumentation
class file for java.lang.instrument.Instrumentation not found

Solution

  • Android only supports a subset of the official Java API. The instrumentation API is not supported by Android what makes agent installation impossible. See the documentation for this limitation.