Android Studio 4.1 com.android.ddmlib.Client changed from class to interface. Now it's incompatible with an IntelliJ IDEA

已回答

I have a plugin https://plugins.jetbrains.com/plugin/11249-okhttp-profiler and it worked well until google released a version of the Android Studio 4.1.

The plugin uses import com.android.ddmlib.Client and import com.android.ddmlib.AndroidDebugBridge

Ddmlib was located as a separate library in the path IntelliJ IDEA CE.app/Contents/plugins/android/lib/ddmlib-26.6.0.2.jar

In the android studio 4.1+ it was moved to a file Android Studio.app/Contents/plugins/android/lib/sdk-tools.jar and the class com.android.ddmlib.Client  was changed to the interface.

Android Studio 4.1 (201.8743.12.41)

package com.android.ddmlib;
public interface Client {

IntellijIDEA 201.8743.12 

package com.android.ddmlib;
public class Client extends JdwpAgent {

The plugin works fine in the IntellijIDEA but has an exception in Android Studio 4.1

java.lang.IncompatibleClassChangeError: Found interface com.android.ddmlib.Client, but class was expected

When I recompiled the plugin with the sources of Android Studio 4.1 it started to work fine there. 

But now it doesn't work in the IntellijIDEA because of the backward exception:

Method AdbController.createProcessList(IDevice) has invocation invokeinterface instruction referencing an interface method Client.getClientData(), but the method's host Client is a class. 
This can lead to IncompatibleClassChangeError at runtime.

Please, help me with how to manage the issue. I can fix it for Android Studio OR for IntellijIDEA but I can't to make it work for both IDE because of the difference of the same class. 

3

It seems the only solution is to provide dedicated version of your plugin targeting specific IDE/version range.

Alternatively, you could try wrapping this in some loader service to load correct implementation via reflection depending on current IDE.

0

Tel me please, how to include sources from `Android Studio.app/Contents/plugins/android/lib/sdk-tools.jar` current plugin ? By default includes classes from ` IntelliJ IDEA CE.app/Contents/plugins/android/lib/ddmlib-26.6.0.2.jar` Thanks!

0

请先登录再写评论。