Closed lassana closed 2 years ago
Java does not have the internal
visibility. Kotlin adds this functionality, but it cannot mark a method as internal
when it compiles to a Java .jar
. Thus, it emits the method as public
and adds a lot of type level metadata that describes what the method is supposed to look like, for example if you were to consume it from a Kotlin application.
So if you view the .jar
/.aar
in a Java decompiler you see the "Java" view of it, which is public
. Our binding tools do the same thing: decompile the .jar
. However, after that, we decode the Kotlin metadata and make changes to the API to make it match the intended Kotlin API. This message is informing you of these changes that were made.
That is, if you were to look at the Kotlin source code, this method was marked internal
by the library authors. This means they do not consider it public API and do not intend for users to use it.
If you want to make it public
anyways for the C# bindings, you can set the visibility
to public
with metadata.
https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata#visibility
That is, if you were to look at the Kotlin source code, this method was marked internal by the library authors. This means they do not consider it public API and do not intend for users to use it.
Very unlikely. They explicitly mention this method in their docs:
class TestApplication: Application() {
override fun onCreate() {
super.onCreate()
//Provide the application context to the SDK
AssistSession.INSTANCE.setContext(this)
}
}
Perhaps. Or they may just have it marked as internal
and don't realize it since it works in Java. 😁
Unfortunately, without some sample Kotlin source code that we can compile and examine if we are interpreting it incorrectly, there isn't much we can do.
But as mentioned, it can be bound as public
if you want with metadata.
@jpobst thanks, your suggestion seems to work well.
Another issue I'm having with this library is that it doesn't work with R8 enabled: the build process passes but the library doesn't work properly. No crash occurs but it seems that some internal things are missing, and only error callbacks are invoked by the library. Unfortunately it is a proprietary SDK so I can't tell what exactly is broken. Disabling R8 fixes the issue.
I've tried to check DEX files with and without R8 enabled side by side but unfortunately I haven't been able to find any missing classes. Do you have any suggestion what I should try next?
When building the app without R8, running it, and invoking the library, the library works well and prints these messages to the logcat:
[System.err] SDKLogger: [INFO] (AssistSession.kt:472) AssistSession : close session
[System.err] SDKLogger: [INFO] (AssistSession.kt:498) AssistSession : Stop Projection
[System.err] SDKLogger: [INFO] (AssistSession.kt:457) AssistSession : Stopped media projection
[System.err] SDKLogger: [INFO] (AssistSession.kt:711) AssistSession : Stop foreground service
[NetworkSecurityConfig] No Network Security Config specified, using platform default
[System.err] SDKLogger: [INFO] (ServerConfig.kt:159) DC : com
[System.err] SDKLogger: [INFO] (AssistSession.kt:442) AssistSession : Start media projection
[System.err] SDKLogger: [INFO] (AssistSession.kt:729) AssistSession : Start foreground service
[System.err] SDKLogger: [INFO] (AssistSession.kt:748) AssistSession : Start chat head service
[FormsActivity] ValidationResponse: (SUCCESS, SUCCESS)
[System.err] SDKLogger: [INFO] (KeepAliveService.kt:71) KeepAliveService : Received Start Foreground Intent
[System.err] SDKLogger: [INFO] (GenerateProtocol.kt:92) request client id : -1
[System.err] SDKLogger: [WARNING] (AgentPluginHelper.kt:154) PLUGIN : Plugin signature doesn't match for any. Google :: Android SDK built for x86
[System.err] SDKLogger: [WARNING] (AgentPluginHelper.kt:155) PLUGIN : Plugin signature: [48, -126, 4, -88, 48, -126, 3, -112, -96, 3, 2, 1, 2, 2, 9, 0, -93, -126, 63, -78, 127, 98, -119, -72, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, 30, 23, 13, 49, 49, 48, 57, 49, 57, 49, 56, 52, 49, 52, 48, 90, 23, 13, 51, 57, 48, 50, 48, 52, 49, 56, 52, 49, 5204-11 18:42:54.887 W/System.err(26811): SDKLogger: [WARNING] (AgentPluginHelper.kt:155) PLUGIN : Plugin signature: [48, -126, 4, -88, 48, -126, 3, -112, -96, 3, 2, 1, 2, 2, 9, 0, -93, -126, 63, -78, 127, 98, -119, -72, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 5, 5, 0, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, 30, 23, 13, 49, 49, 48, 57, 49, 57, 49, 56, 52, 49, 52, 48, 90, 23, 13, 51, 57, 48, 50, 48, 52, 49, 56, 52, 49, 52, 48, 90, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, -126, 1, 32, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 13, 0, 48, -126, 1, 8, 2, -126, 1, 1, 0, -51, 66, 31, -7, 59, -108, -91, -54, -38, 26, -32, 40, 61, 1, -86, 32, -1, 89, 42, 20, 99, 22, -110, 108, -46, 109, -22, -31, 4, 2, 79, 90, 92, 118, -85, -83, 53, 3, -83, 91, -46, 88, -6, -90, 66, -111, 22, -69, 85, -123, -91, 49, -62, -10, 2, 4, 72, -120, -6, 48, 90, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, 48, -126, 1, 32, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -126, 1, 13, 0, 48, -126, 1, 8, 2, -126, 1, 1, 0, -51, 66, 31, -7, 59, -108, -91, -54, -38, 26, -32, 40, 61, 1, -86, 32, -1, 89, 42, 20, 99, 22, -110, 108, -46, 109, -22, -31, 4, 2, 79, 90, 92, 118, -85, -83, 53, 3, -83, 91, -46, 88, -6, -90, 66, -111, 22, -69, 85, -123, -91, 49, -62, -10, 2, 4, 72, -120, -67, -122, -93, 47, 18, -35, -81, 83, -62, -8, 66, 94, 48, -127, -55, 6, 3, 85, 29, 35, 4, -127, -63, 48, -127, -66, -128, 20, 38, 3, -56, 118, 30, 52, 83, 71, 117, -122, -93, 47, 18, -35, -81, 83, -62, -8, 66, 94, -95, -127, -102, -92, -127, -105, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, -126, 9, 0, -93, -126, 63, -78, 127, 98, -119, -72, 48, 12, 6, 3, 85, 29, 19, 4, 5, 48, 3, 1, 1, -1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,7, -122, -93, 47, 18, -35, -81, 83, -62, -8, 66, 94, 48, -127, -55, 6, 3, 85, 29, 35, 4, -127, -63, 48, -127, -66, -128, 20, 38, 3, -56, 118, 30, 52, 83, 71, 117, -122, -93, 47, 18, -35, -81, 83, -62, -8, 66, 94, -95, -127, -102, -92, -127, -105, 48, -127, -108, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 83, 49, 19, 48, 17, 6, 3, 85, 4, 8, 19, 10, 67, 97, 108, 105, 102, 111, 114, 110, 105, 97, 49, 22, 48, 20, 6, 3, 85, 4, 7, 19, 13, 77, 111, 117, 110, 116, 97, 105, 110, 32, 86, 105, 101, 119, 49, 16, 48, 14, 6, 3, 85, 4, 10, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 11, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 16, 48, 14, 6, 3, 85, 4, 3, 19, 7, 65, 110, 100, 114, 111, 105, 100, 49, 34, 48, 32, 6, 9, 42, -122, 72, -122, -9, 13, 1, 9, 1, 22, 19, 97, 110, 100, 114, 111, 105, 100, 64, 97, 110, 100, 114, 111, 105, 100, 46, 99, 111, 109, -126, 9, 0, -93, -126, 63, -78, 127, 98, -119, -72, 48, 12, 6, 3, 85, 29, 19, 4, 5, 48, 3, 1, 1, -1, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1,
[System.err] SDKLogger: [INFO] (AgentPluginHelper.kt:161) PLUGIN : init plugin package name ::
[System.err] SDKLogger: [INFO] (GenerateProtocol.kt:130) ELM_KEY : false
[System.err] SDKLogger: [INFO] (WebSocketClient.kt:145) AssistSession : 865454734
[System.err] SDKLogger: [INFO] (GenerateProtocol.kt:92) request client id : -1
[System.err] SDKLogger: [INFO] (GenerateProtocol.kt:130) ELM_KEY : false
[System.err] SDKLogger: [INFO] (WebSocketClient.kt:145) AssistSession : 865454734
[System.err] SDKLogger: [INFO] (WebSocketClient.kt:965) onConnectionChangeJSON : {"byte_size":0,"c_version":"2","c_module":"HTML5_WS","c_email":"john@example.com","res_y":"-1","c_role":"VIEWER","c_ip":"135.125.132.170","res_x":"-1","c_devicename":"-1","c_os_type":"Mac","protocol":"CONN","c_tech":"HTML5_WS","participant_role":0,"c_id":"1248798552","c_name":"Mikalai","comment":"-1","state":"UP"}
[System.err] SDKLogger: [INFO] (GenerateProtocol.kt:175) CONTROL : MOBILE_AGENT CONTROL_STATUS: FALSE : GOOGLE
But like I said the library is broken with R8 enabled. Here is the logcat output:
[System.err] SDKLogger: [INFO] (null:6) AssistSession : close session
[System.err] SDKLogger: [INFO] (null:26) AssistSession : Stop Projection
[System.err] SDKLogger: [INFO] (null:6) AssistSession : Stopped media projection
[System.err] SDKLogger: [INFO] (null:6) AssistSession : Stop foreground service
[System.err] SDKLogger: [INFO] (null:511) DC : com
It looks like something critical is missing (see these nulls) but I don't really know how to investigate this.
Repro: ZohoAssist.zip
I'm afraid I don't know much about R8. Perhaps @jonathanpeppers or @dellis1972 know more.
@lassana I would try the dexdump
command on the classes.dex
in your app. I can't find good docs on this tool:
http://manpages.ubuntu.com/manpages/bionic/man1/dexdump.1.html
Mine is at C:\Program Files (x86)\Android\android-sdk\build-tools\30.0.3\dexdump.exe
, for example.
When r8 "treeshakes" your app, figure out what types are missing that it needs compared to when not using r8. Then add those to your proguard.cfg
file?
When r8 "treeshakes" your app, figure out what types are missing that it needs compared to when not using r8. Then add those to your proguard.cfg file?
Originally I added keep class ** { *; }
but that didn't really helped. I ended up with copying R8 rules from the kotlin.reflect.jvm
package from here, that worked. Not really sure whether Xamarin should handle it by itself.
Anyway, feel free to close the issue.
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
Xamarin.Android Version: 12.0.0.3 (Visual Studio Community)
Description
I'm working on Xamarin bindings for the Zoho Assist SDK. Everything seems to bind well except that
AssistSession
class missessetContext()
method. In the build output I've found this:Classyshark recognizes
AssistSession#setContext()
as a valid public method:Steps to Reproduce
ZohoAssist.Droid
ZohoAssist.zip
Diagnostic build output: log.txt
Did you find any workaround?
No response
Relevant log output