CommunityToolkit / Maui.NativeLibraryInterop

Maui.NativeLibraryInterop is a community-created library of binding samples to help .NET MAUI developers interop with native libraries more easily
MIT License
179 stars 28 forks source link

How to Facebook or other SDK (eg SumUp) working? #44

Open iqmeta opened 3 months ago

iqmeta commented 3 months ago

When I clone the repo, and run it out of the box I get this:

image image

I tried the template exactly like in the docs, trying to get sumup running with android:

Just some examples:

plugins {
    id("com.android.library")
}

android {
    namespace = "com.example.newbinding"
    compileSdk = 34

    defaultConfig {
        minSdk = 26
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

// Create configuration for copyDependencies
configurations {
    all{
        setTransitive(true)
    }
    create("copyDependencies")
}

dependencies {

    implementation("com.sumup:merchant-sdk:5.0.1")
    "copyDependencies"("com.sumup:merchant-sdk:5.0.1")
}

// Copy dependencies for binding library
project.afterEvaluate {
    tasks.register<Copy>("copyDeps") {
        from(configurations["copyDependencies"])
        into("${buildDir}/outputs/deps")
    }
    tasks.named("preBuild") { finalizedBy("copyDeps") }
}

----------------

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
         maven {
            url = uri("https://maven.sumup.com/releases")
         }
    }
}

Everythings compile nice and right. But I'm not able to get it run. Bit trouble to get the deps into the app.

Tried lots of things. Like this

        <GradleRepository Include="https://maven.sumup.com/releases">
            <Repository>
                maven {
                url = uri("https://maven.sumup.com/releases")
                }
            </Repository>
        </GradleRepository>
        <AndroidLibrary Include="C:\Temp\template\android\NewBinding.Android.Binding\bin\Debug\net9.0-android\newbinding-Release.aar">
            <Bind>false</Bind>
            <Visible>false</Visible>
        </AndroidLibrary>

or this.... guess its to new, fails with Xamarin Nuget.ProjectModel instant on Build Xamarin Target Tools: https://learn.microsoft.com/en-us/dotnet/android/features/maven/android-maven-library

Any idea how to get all deps with Gradle / Android Studio into the App?


**Java.Lang.NoClassDefFoundError:** 'Failed resolution of: Lcom/sumup/merchant/reader/api/SumUpState;'

[EGL_emulation] app_time_stats: avg=1.80ms min=1.34ms max=3.09ms count=60
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/sumup/merchant/reader/api/SumUpState;
[mono-rt]  ---> Java.Lang.ClassNotFoundException: Didn't find class "com.sumup.merchant.reader.api.SumUpState" on path: DexPathList[[zip file "/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/lib/x86_64, /data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[mono-rt] 
[mono-rt]   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
[mono-rt] java.lang.ClassNotFoundException: Didn't find class "com.sumup.merchant.reader.api.SumUpState" on path: DexPathList[[zip file "/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/lib/x86_64, /data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[mono-rt]   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
[mono-rt]   at com.example.newbinding.DotnetNewBinding.Init2(DotnetNewBinding.java:24)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29)
[mono-rt]   at android.view.View.performClick(View.java:8028)
[mono-rt]   at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1211)
[mono-rt]   at android.view.View.performClickInternal(View.java:8005)
[mono-rt]   at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
[mono-rt]   at android.view.View$PerformClick.run(View.java:31229)
[mono-rt]   at android.os.Handler.handleCallback(Handler.java:959)
[mono-rt]   at android.os.Handler.dispatchMessage(Handler.java:100)
[mono-rt]   at android.os.Looper.loopOnce(Looper.java:232)
[mono-rt]   at android.os.Looper.loop(Looper.java:317)
[mono-rt]   at android.app.ActivityThread.main(ActivityThread.java:8705)
[mono-rt]   at java.lang.reflect.Method.invoke(Native Method)
[mono-rt]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[mono-rt]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
[mono-rt] 
[mono-rt]   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
[mono-rt] java.lang.ClassNotFoundException: Didn't find class "com.sumup.merchant.reader.api.SumUpState" on path: DexPathList[[zip file "/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/lib/x86_64, /data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[mono-rt]   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
[mono-rt]   at com.example.newbinding.DotnetNewBinding.Init2(DotnetNewBinding.java:24)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29)
[mono-rt]   at android.view.View.performClick(View.java:8028)
[mono-rt]   at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1211)
[mono-rt]   at android.view.View.performClickInternal(View.java:8005)
[mono-rt]   at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
[mono-rt]   at android.view.View$PerformClick.run(View.java:31229)
[mono-rt]   at android.os.Handler.handleCallback(Handler.java:959)
[mono-rt]   at android.os.Handler.dispatchMessage(Handler.java:100)
[mono-rt]   at android.os.Looper.loopOnce(Looper.java:232)
[mono-rt]   at android.os.Looper.loop(Looper.java:317)
[mono-rt]   at android.app.ActivityThread.main(ActivityThread.java:8705)
[mono-rt]   at java.lang.reflect.Method.invoke(Native Method)
[mono-rt]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[mono-rt]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
[mono-rt] 
[mono-rt]    --- End of inner exception stack trace ---
[mono-rt]    at Java.Interop.JniEnvironment.StaticMethods.CallStaticVoidMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net8.0/JniEnvironment.g.cs:line 21831
[mono-rt]    at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeVoidMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 111
[mono-rt]    at NewBindingAndroid.DotnetNewBinding.Init2(Activity activity) in C:\Temp\template\android\NewBinding.Android.Binding\obj\Debug
et9.0-android\generated\src\NewBindingAndroid.DotnetNewBinding.cs:line 74
[mono-rt]    at MyApp.Views.MainPage.OnCounterClicked(Object sender, EventArgs e) in C:\Temp\MyApp\Views\MainPage.xaml.cs:line 22
[mono-rt]    at Microsoft.Maui.Controls.Button.Microsoft.Maui.Controls.Internals.IButtonElement.PropagateUpClicked() in /_/src/Controls/src/Core/Button/Button.cs:line 275
[mono-rt]    at Microsoft.Maui.Controls.ButtonElement.ElementClicked(VisualElement visualElement, IButtonElement ButtonElementManager) in /_/src/Controls/src/Core/Button/ButtonElement.cs:line 40
[mono-rt]    at Microsoft.Maui.Controls.Button.SendClicked() in /_/src/Controls/src/Core/Button/Button.cs:line 250
[mono-rt]    at Microsoft.Maui.Controls.Button.Microsoft.Maui.IButton.Clicked() in /_/src/Controls/src/Core/Button/Button.cs:line 484
[mono-rt]    at Microsoft.Maui.Handlers.ButtonHandler.OnClick(IButton button, View v) in /_/src/Core/src/Handlers/Button/ButtonHandler.Android.cs:line 151
[mono-rt]    at Microsoft.Maui.Handlers.ButtonHandler.ButtonClickListener.OnClick(View v) in /_/src/Core/src/Handlers/Button/ButtonHandler.Android.cs:line 172
[mono-rt]    at Android.Views.View.IOnClickListenerInvoker.n_OnClick_Landroid_view_View_(IntPtr jnienv, IntPtr native__this, IntPtr native_v) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net9.0/android-34/mcw/Android.Views.View.cs:line 2284
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 121
[mono-rt]   --- End of managed Java.Lang.NoClassDefFoundError stack trace ---
[mono-rt] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sumup/merchant/reader/api/SumUpState;
[mono-rt]   at com.example.newbinding.DotnetNewBinding.Init2(DotnetNewBinding.java:24)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29)
[mono-rt]   at android.view.View.performClick(View.java:8028)
[mono-rt]   at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1211)
[mono-rt]   at android.view.View.performClickInternal(View.java:8005)
[mono-rt]   at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
[mono-rt]   at android.view.View$PerformClick.run(View.java:31229)
[mono-rt]   at android.os.Handler.handleCallback(Handler.java:959)
[mono-rt]   at android.os.Handler.dispatchMessage(Handler.java:100)
[mono-rt]   at android.os.Looper.loopOnce(Looper.java:232)
[mono-rt]   at android.os.Looper.loop(Looper.java:317)
[mono-rt]   at android.app.ActivityThread.main(ActivityThread.java:8705)
[mono-rt]   at java.lang.reflect.Method.invoke(Native Method)
[mono-rt]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[mono-rt]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
[mono-rt] Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sumup.merchant.reader.api.SumUpState" on path: DexPathList[[zip file "/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/lib/x86_64, /data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[mono-rt]   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
[mono-rt]   ... 16 more
[mono-rt] 
[mono-rt]   --- End of managed Java.Lang.NoClassDefFoundError stack trace ---
[mono-rt] java.lang.NoClassDefFoundError: Failed resolution of: Lcom/sumup/merchant/reader/api/SumUpState;
[mono-rt]   at com.example.newbinding.DotnetNewBinding.Init2(DotnetNewBinding.java:24)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.n_onClick(Native Method)
[mono-rt]   at crc64fcf28c0e24b4cc31.ButtonHandler_ButtonClickListener.onClick(ButtonHandler_ButtonClickListener.java:29)
[mono-rt]   at android.view.View.performClick(View.java:8028)
[mono-rt]   at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1211)
[mono-rt]   at android.view.View.performClickInternal(View.java:8005)
[mono-rt]   at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
[mono-rt]   at android.view.View$PerformClick.run(View.java:31229)
[mono-rt]   at android.os.Handler.handleCallback(Handler.java:959)
[mono-rt]   at android.os.Handler.dispatchMessage(Handler.java:100)
[mono-rt]   at android.os.Looper.loopOnce(Looper.java:232)
[mono-rt]   at android.os.Looper.loop(Looper.java:317)
[mono-rt]   at android.app.ActivityThread.main(ActivityThread.java:8705)
[mono-rt]   at java.lang.reflect.Method.invoke(Native Method)
[mono-rt]   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
[mono-rt]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
[mono-rt] Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sumup.merchant.reader.api.SumUpState" on path: DexPathList[[zip file "/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/lib/x86_64, /data/app/~~XzXtQzwGXUNhI5X4xPN1FQ==/com.companyname.myapp-ZA9m4nK9KcIrxXLz4E0plQ==/base.apk!/lib/x86_64, /system/lib64, /system_ext/lib64]]
[mono-rt]   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
[mono-rt]   at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
[mono-rt]   ...
``` 16 more
[mono-rt] 
rachelkang commented 1 month ago

Hi, @iqmeta - Thank you for using Maui.NativeLibraryInterop and reporting this issue. Please make sure that you have configured the app identifiers correctly as indicated in the README at https://github.com/CommunityToolkit/Maui.NativeLibraryInterop/tree/main/facebook. If you continue to run into any issues after that, please let us know!