raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.29k stars 807 forks source link

Doesn't seem to work properly on Android #1541

Closed axhlzy closed 1 year ago

axhlzy commented 1 year ago

E  FATAL EXCEPTION: main

                                                                                                    Process: com.ttt.injectdemo, PID: 18567
                                                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ttt.injectdemo/com.example.ttt.MainActivity}: java.lang.IllegalStateException: Cannot load class class net.bytebuddy.renamed.java.util.function.Function$ByteBuddy$RdLtdWf0
                                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3308)
                                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
                                                                                                        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
                                                                                                        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
                                                                                                        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                                                        at android.os.Looper.loop(Looper.java:224)
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7562)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
                                                                                                    Caused by: java.lang.IllegalStateException: Cannot load class class net.bytebuddy.renamed.java.util.function.Function$ByteBuddy$RdLtdWf0
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.load(ByteArrayClassLoader.java:367)
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$WrappingDispatcher.load(ClassLoadingStrategy.java:367)
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:148)
                                                                                                        at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6325)
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6313)
                                                                                                        at com.example.ttt.MainActivity.onCreate(MainActivity.java:118)
                                                                                                        at android.app.Activity.performCreate(Activity.java:7893)
                                                                                                        at android.app.Activity.performCreate(Activity.java:7880)
                                                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
                                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
                                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457) 
                                                                                                        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                        at android.os.Looper.loop(Looper.java:224) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7562) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
                                                                                                    Caused by: java.lang.ClassNotFoundException: net.bytebuddy.renamed.java.util.function.Function$ByteBuddy$RdLtdWf0
                                                                                                        at java.lang.Class.classForName(Native Method)
                                                                                                        at java.lang.Class.forName(Class.java:454)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.load(ByteArrayClassLoader.java:361)
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$WrappingDispatcher.load(ClassLoadingStrategy.java:367) 
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:148) 
                                                                                                        at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101) 
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6325) 
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6313) 
                                                                                                        at com.example.ttt.MainActivity.onCreate(MainActivity.java:118) 
                                                                                                        at android.app.Activity.performCreate(Activity.java:7893) 
                                                                                                        at android.app.Activity.performCreate(Activity.java:7880) 
                                                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) 
                                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283) 
                                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457) 
                                                                                                        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                        at android.os.Looper.loop(Looper.java:224) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7562) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
                                                                                                    Caused by: java.lang.UnsupportedOperationException: can't load this type of class file
                                                                                                        at java.lang.ClassLoader.defineClass(ClassLoader.java:591)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.access$300(ByteArrayClassLoader.java:57)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$ClassDefinitionAction.run(ByteArrayClassLoader.java:687)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader$ClassDefinitionAction.run(ByteArrayClassLoader.java:639)
                                                                                                        at java.security.AccessController.doPrivileged(AccessController.java:59)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.doPrivileged(Unknown Source:6)
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.findClass(ByteArrayClassLoader.java:406)
                                                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                                        at java.lang.Class.classForName(Native Method) 
                                                                                                        at java.lang.Class.forName(Class.java:454) 
                                                                                                        at net.bytebuddy.dynamic.loading.ByteArrayClassLoader.load(ByteArrayClassLoader.java:361) 
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$WrappingDispatcher.load(ClassLoadingStrategy.java:367) 
                                                                                                        at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:148) 
                                                                                                        at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101) 
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6325) 
                                                                                                        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6313) 
                                                                                                        at com.example.ttt.MainActivity.onCreate(MainActivity.java:118) 
                                                                                                        at android.app.Activity.performCreate(Activity.java:7893) 
                                                                                                        at android.app.Activity.performCreate(Activity.java:7880) 
                                                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307) 
                                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283) 
                                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457) 
                                                                                                        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
                                                                                                        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                                                        at android.os.Looper.loop(Looper.java:224) 
                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:7562) 
                                                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
raphw commented 1 year ago

Did you have a look at byte-buddy-android?