dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

"Kotlin: Hiding internal setter method" when binding an Android library #6902

Closed lassana closed 2 years ago

lassana commented 2 years ago

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 misses setContext() method. In the build output I've found this:

    Kotlin: Hiding internal setter method com/zoho/assist/customer/AssistSession - setContext

Classyshark recognizes AssistSession#setContext() as a valid public method:

Screen Shot 2022-04-07 at 1 38 31 PM

Steps to Reproduce

  1. Open attached solution
  2. Build ZohoAssist.Droid

ZohoAssist.zip

Diagnostic build output: log.txt

Did you find any workaround?

No response

Relevant log output

See above
jpobst commented 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

lassana commented 2 years ago

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)
    }
}
jpobst commented 2 years ago

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.

lassana commented 2 years ago

@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?

R8 task output ``` Using "R8" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll". Task "R8" processing ClassesZip, JavaLibrariesToEmbed... /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/bin/java -Xmx1G -classpath /Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/r8.jar com.android.tools.r8.R8 --release --min-api 21 --output obj/Release/android/bin/ --lib /usr/local/share/android-sdk/platforms/android-30/android.jar --lib /usr/local/share/android-sdk/platforms/android-30/optional/org.apache.http.legacy.jar obj/Release/android/bin/classes.zip /Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v11.0/mono.android.jar /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/java_runtime.jar /Users/user/.nuget/packages/xamarin.androidx.annotation/1.2.0.1/buildTransitive/monoandroid90/../../jar/androidx.annotation.annotation.jar /Users/user/.nuget/packages/xamarin.androidx.collection/1.1.0.8/buildTransitive/monoandroid90/../../jar/androidx.collection.collection.jar /Users/user/.nuget/packages/xamarin.androidx.lifecycle.common/2.3.1.1/buildTransitive/monoandroid90/../../jar/androidx.lifecycle.lifecycle-common.jar /Users/user/.nuget/packages/xamarin.androidx.arch.core.common/2.1.0.9/buildTransitive/monoandroid90/../../jar/androidx.arch.core.core-common.jar /Users/user/.nuget/packages/xamarin.androidx.constraintlayout.solver/2.0.2/buildTransitive/monoandroid90/../../jar/androidx.constraintlayout.constraintlayout-solver.jar /Users/user/.nuget/packages/xamarin.androidx.databinding.databindingcommon/4.2.2.1/buildTransitive/monoandroid90/../../jar/androidx.databinding.databinding-common.jar obj/Release/androidx/jl/0ed98962-be69-49bb-97ce-4c76f88915a3.jar obj/Release/androidx/jl/13aa4d62-351d-4099-847a-e36baf03271f.jar obj/Release/androidx/jl/3f9339c5-5425-49a7-be9b-3e12a27e9b5f.jar obj/Release/androidx/jl/e0675abf-0c46-424d-b682-de0c3f865eb3.jar obj/Release/lp/135/jl/classes.jar obj/Release/lp/132/jl/classes.jar obj/Release/lp/104/jl/classes.jar obj/Release/lp/168/jl/classes.jar obj/Release/lp/157/jl/classes.jar obj/Release/lp/150/jl/classes.jar obj/Release/lp/159/jl/classes.jar obj/Release/lp/166/jl/classes.jar obj/Release/lp/161/jl/classes.jar obj/Release/lp/102/jl/protobuf-lite-3.0.1.jar obj/Release/lp/105/jl/classes.jar obj/Release/lp/133/jl/classes.jar obj/Release/lp/134/jl/classes.jar obj/Release/lp/160/jl/classes.jar obj/Release/lp/158/jl/classes.jar obj/Release/lp/167/jl/classes.jar obj/Release/lp/151/jl/classes.jar obj/Release/lp/169/jl/classes.jar obj/Release/lp/156/jl/classes.jar obj/Release/lp/174/jl/classes.jar obj/Release/lp/180/jl/classes.jar obj/Release/lp/173/jl/classes.jar obj/Release/lp/0/jl/gson.jar obj/Release/lp/145/jl/classes.jar obj/Release/lp/142/jl/classes.jar obj/Release/lp/7/jl/convertergson.jar obj/Release/lp/129/jl/classes.jar obj/Release/lp/116/jl/classes.jar obj/Release/lp/111/jl/classes.jar obj/Release/lp/118/jl/classes.jar obj/Release/lp/127/jl/classes.jar obj/Release/lp/120/jl/classes.jar obj/Release/lp/6/jl/okio.jar obj/Release/lp/143/jl/classes.jar obj/Release/lp/144/jl/classes.jar obj/Release/lp/1/jl/__reference__kotlin-android-extensions-runtime-1.3.50.jar obj/Release/lp/172/jl/classes.jar obj/Release/lp/8/jl/retrofit2.jar obj/Release/lp/175/jl/classes.jar obj/Release/lp/121/jl/classes.jar obj/Release/lp/119/jl/classes.jar obj/Release/lp/126/jl/classes.jar obj/Release/lp/110/jl/classes.jar obj/Release/lp/128/jl/classes.jar obj/Release/lp/117/jl/classes.jar obj/Release/lp/153/jl/classes.jar obj/Release/lp/154/jl/classes.jar obj/Release/lp/162/jl/classes.jar obj/Release/lp/165/jl/classes.jar obj/Release/lp/131/jl/classes.jar obj/Release/lp/136/jl/classes.jar obj/Release/lp/109/jl/classes.jar obj/Release/lp/107/jl/classes.jar obj/Release/lp/138/jl/classes.jar obj/Release/lp/164/jl/classes.jar obj/Release/lp/163/jl/classes.jar obj/Release/lp/155/jl/classes.jar obj/Release/lp/152/jl/classes.jar obj/Release/lp/106/jl/classes.jar obj/Release/lp/139/jl/classes.jar obj/Release/lp/137/jl/classes.jar obj/Release/lp/108/jl/classes.jar obj/Release/lp/63/jl/firebase-annotations.jar obj/Release/lp/130/jl/classes.jar obj/Release/lp/112/jl/classes.jar obj/Release/lp/115/jl/classes.jar obj/Release/lp/83/jl/dagger.jar obj/Release/lp/123/jl/classes.jar obj/Release/lp/124/jl/classes.jar obj/Release/lp/148/jl/classes.jar obj/Release/lp/141/jl/classes.jar obj/Release/lp/4/jl/okhttp3.jar obj/Release/lp/3/jl/nv-websocket-client-2.9.jar obj/Release/lp/146/jl/classes.jar obj/Release/lp/179/jl/classes.jar obj/Release/lp/125/jl/classes.jar obj/Release/lp/122/jl/classes.jar obj/Release/lp/114/jl/classes.jar obj/Release/lp/113/jl/classes.jar obj/Release/lp/147/jl/classes.jar obj/Release/lp/5/jl/logging-interceptor.jar obj/Release/lp/140/jl/classes.jar obj/Release/lp/176/jl/classes.jar obj/Release/lp/149/jl/classes.jar obj/Release/lp/171/jl/classes.jar obj/Release/lp/103/jl/bin/classes.jar obj/Release/lp/103/jl/libs/com.sonymobile.enterprise.support.jar obj/Release/lp/103/jl/libs/com.sonymobile.enterprise.jar obj/Release/lp/80/jl/bin/classes.jar obj/Release/lp/81/jl/bin/classes.jar obj/Release/lp/79/jl/bin/classes.jar obj/Release/lp/2/jl/bin/classes.jar --pg-conf /usr/local/share/android-sdk/tools/proguard/proguard-android.txt --pg-conf obj/Release/proguard/proguard_xamarin.cfg --pg-conf obj/Release/proguard/proguard_project_references.cfg --pg-conf obj/Release/proguard/proguard_project_primary.cfg --pg-conf /Users/user/.nuget/packages/xamarin.androidx.versionedparcelable/1.1.1.8/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.lifecycle.runtime/2.3.1.2/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.annotation.experimental/1.1.0.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.core/1.6.0.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.savedstate/1.1.0.2/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.lifecycle.viewmodel/2.3.1.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.lifecycle.viewmodelsavedstate/2.3.1.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.fragment/1.3.6.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.recyclerview/1.2.1.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.vectordrawable.animated/1.1.0.2/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.transition/1.4.1.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.coordinatorlayout/1.1.0.8/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.appcompat/1.1.0.2/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.google.android.material/1.4.0.2/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.databinding.databindingruntime/4.2.2.1/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf /Users/user/.nuget/packages/xamarin.androidx.media/1.2.0/buildTransitive/monoandroid90/../../proguard/proguard.txt --pg-conf obj/Release/androidx/proguard/0210ace8-c235-40b7-bdc9-0631d634b80a.txt --pg-conf obj/Release/androidx/proguard/06c47e62-d169-421a-9f69-4baa5a134528.txt --pg-conf obj/Release/androidx/proguard/0a568483-44a5-4717-ae43-9da837ac6862.txt --pg-conf obj/Release/androidx/proguard/0bfe3f97-1da9-4d27-ab10-386e8640a782.txt --pg-conf obj/Release/androidx/proguard/16f1f9db-c356-4b6d-b974-e2fb818151a2.txt --pg-conf obj/Release/androidx/proguard/35979970-4b5d-4db8-8d68-34b4db63ac93.txt --pg-conf obj/Release/androidx/proguard/47832559-119c-4a81-b4c0-8e89277d9837.txt --pg-conf obj/Release/androidx/proguard/6260dd57-6d42-487f-b262-7e18f70d9a0a.txt --pg-conf obj/Release/androidx/proguard/66df2eec-7b68-4e75-a30a-cce9c6ea160e.cfg --pg-conf obj/Release/androidx/proguard/6aba47d2-82f5-406b-8cf6-06286fed8e3e.txt --pg-conf obj/Release/androidx/proguard/6d6bc26d-f9eb-4922-a3ac-5683d84400cf.txt --pg-conf obj/Release/androidx/proguard/80a46bea-83b3-4b82-bfdd-890efc905da2.txt --pg-conf obj/Release/androidx/proguard/9479dcd4-6251-4cf9-a204-61f95641efa3.txt --pg-conf obj/Release/androidx/proguard/adf18243-fe86-4e10-92da-38ef4b4208a3.txt --pg-conf obj/Release/androidx/proguard/ef6b6b29-7545-485c-b218-c9feb3bf8bef.txt --pg-conf obj/Release/androidx/proguard/f9047ee6-4124-4912-a040-4b188f74fdd3.txt R8 : warning : Missing class: org.conscrypt.ConscryptHostnameVerifier R8 : warning : Missing class: javax.inject.Provider Warning in obj/Release/lp/103/jl/bin/classes.jar:com/zoho/assist/customer/databinding/ChatRowLayoutBindingImpl.class: Type `androidx.databinding.adapters.ViewBindingAdapter` was not found, it is required for default or static interface methods desugaring of `Lcom/zoho/assist/customer/databinding/ChatRowLayoutBindingImpl;executeBindings()V` Warning in obj/Release/lp/103/jl/bin/classes.jar:com/zoho/assist/customer/databinding/ChatRowLayoutBindingImpl.class: Type `androidx.databinding.adapters.TextViewBindingAdapter` was not found, it is required for default or static interface methods desugaring of `Lcom/zoho/assist/customer/databinding/ChatRowLayoutBindingImpl;executeBindings()V` Warning in obj/Release/lp/4/jl/okhttp3.jar:okhttp3/internal/platform/ConscryptPlatform$Companion.class: Type `org.conscrypt.Conscrypt` was not found, it is required for default or static interface methods desugaring of `Lokhttp3/internal/platform/ConscryptPlatform$Companion;atLeastVersion(III)Z` Warning in obj/Release/lp/83/jl/dagger.jar:dagger/internal/Factory.class: Type `javax.inject.Provider` was not found, it is required for default or static interface methods desugaring of `dagger.internal.Factory` Warning in obj/Release/lp/4/jl/okhttp3.jar:okhttp3/internal/platform/ConscryptPlatform$configureTrustManager$1.class: Type `org.conscrypt.ConscryptHostnameVerifier` was not found, it is required for default or static interface methods desugaring of `okhttp3.internal.platform.ConscryptPlatform$configureTrustManager$1` Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MSFTSIG.SF' already exists. Warning: Resource 'META-INF/MSFTSIG.RSA' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MSFTSIG.SF' already exists. Warning: Resource 'META-INF/MSFTSIG.RSA' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MSFTSIG.SF' already exists. Warning: Resource 'META-INF/MSFTSIG.RSA' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MSFTSIG.SF' already exists. Warning: Resource 'META-INF/MSFTSIG.RSA' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. Warning: Resource 'META-INF/MANIFEST.MF' already exists. InnerClasses attribute has entries missing a corresponding EnclosingMethod attribute. Such InnerClasses attribute entries are ignored. In obj/Release/lp/164/jl/classes.jar:com/google/android/gms/measurement/internal/zzfb$zza.class: Classes with missing EnclosingMethod: com.google.android.gms.measurement.internal.zzfb$zza Done executing task "R8". ```
proguard.cfg ``` -keep class androidx.startup.AppInitializer -keep class * extends androidx.startup.Initializer -keep class com.google.firebase.provider.FirebaseInitProvider -keep public class androidx.appcompat.widget.** { *; } -keep class com.zoho.** { *; } -keep class retrofit2.** { *; } -keep class okhttp3.** { *; } -keep class okio.** { *; } -keep class dagger.** { *; } -keep class com.sonymobile.enterprise.** { *; } ```

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

jpobst commented 2 years ago

I'm afraid I don't know much about R8. Perhaps @jonathanpeppers or @dellis1972 know more.

jonathanpeppers commented 2 years ago

@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?

lassana commented 2 years ago

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.