Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed resolution of: Landroidx/activity/OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1; after updating to 8.0.91 #9428

Open
skolumban-ex opened this issue Oct 17, 2024 · 11 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. need-info Issues that need more information from the author.

Comments

@skolumban-ex
Copy link

skolumban-ex commented Oct 17, 2024

Description

I am maintaining a MAUI app, using .Net 8. The MAUI nuget versions are 8.0.91 (I updated from 8.0.71).

The application runs fine on all my devices and on emulator. But it cannot be released on Google Play, as Google refuses it because of broken functionality (the app crashes on startup).

The Sentry logs are showing two issues:

Issue 1:

java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/activity/OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1;
at androidx.activity.OnBackPressedDispatcher$Api34Impl.createOnBackAnimationCallback(OnBackPressedDispatcher.kt:385)
at androidx.activity.OnBackPressedDispatcher.(OnBackPressedDispatcher.kt:127)
at androidx.activity.OnBackPressedDispatcher.(OnBackPressedDispatcher.kt:77)
at androidx.activity.ComponentActivity$onBackPressedDispatcher$2.invoke(ComponentActivity.kt:622)
at androidx.activity.ComponentActivity$onBackPressedDispatcher$2.invoke(ComponentActivity.kt:621)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at androidx.activity.ComponentActivity.getOnBackPressedDispatcher(ComponentActivity.kt:621)
at androidx.fragment.app.FragmentActivity$HostCallbacks.getOnBackPressedDispatcher(FragmentActivity.java:607)
at androidx.fragment.app.FragmentManager.attachController(FragmentManager.java:2919)
at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:117)
at androidx.fragment.app.FragmentActivity.lambda$init$3$androidx-fragment-app-FragmentActivity(FragmentActivity.java:139)
at androidx.fragment.app.FragmentActivity$$ExternalSyntheticLambda3.onContextAvailable
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.kt:84)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.kt:331)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:216)
at crc64a98f21486839a9f0.MainActivity.n_onCreate(MainActivity.java)
at crc64a98f21486839a9f0.MainActivity.onCreate(MainActivity.java:51)
at android.app.Activity.performCreate(Activity.java:7994)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1548)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3406)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3607)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
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:2068)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7680)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:423)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
java.lang.ClassNotFoundException: androidx.activity.OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1
at androidx.activity.OnBackPressedDispatcher$Api34Impl.createOnBackAnimationCallback(OnBackPressedDispatcher.kt:385)
at androidx.activity.OnBackPressedDispatcher.(OnBackPressedDispatcher.kt:127)
at androidx.activity.OnBackPressedDispatcher.(OnBackPressedDispatcher.kt:77)
at androidx.activity.ComponentActivity$onBackPressedDispatcher$2.invoke(ComponentActivity.kt:622)
at androidx.activity.ComponentActivity$onBackPressedDispatcher$2.invoke(ComponentActivity.kt:621)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at androidx.activity.ComponentActivity.getOnBackPressedDispatcher(ComponentActivity.kt:621)
at androidx.fragment.app.FragmentActivity$HostCallbacks.getOnBackPressedDispatcher(FragmentActivity.java:607)
at androidx.fragment.app.FragmentManager.attachController(FragmentManager.java:2919)
at androidx.fragment.app.FragmentController.attachHost(FragmentController.java:117)
at androidx.fragment.app.FragmentActivity.lambda$init$3$androidx-fragment-app-FragmentActivity(FragmentActivity.java:139)
at androidx.fragment.app.FragmentActivity$$ExternalSyntheticLambda3.onContextAvailable
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.kt:84)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.kt:331)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:216)
at crc64a98f21486839a9f0.MainActivity.n_onCreate(MainActivity.java)
at crc64a98f21486839a9f0.MainActivity.onCreate(MainActivity.java:51)
at android.app.Activity.performCreate(Activity.java:7994)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1548)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3406)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3607)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
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:2068)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7680)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:423)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Issue 2:

Java.Lang.Error: Failed resolution of: Landroidx/activity/OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1;
?, in void InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference, JniObjectReference, JniMethodInfo, JniArgumentValue*)
?, in void JniInstanceMethods.InvokeVirtualVoidMethod(string, IJavaPeerable, JniArgumentValue*)
?, in void Activity.OnCreate(Bundle)
?, in void MauiAppCompatActivity.OnCreate(Bundle savedInstanceState)
?, in void MainActivity.OnCreate(Bundle savedInstanceState)
?, in void Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState)
?, in void JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0)

Steps to Reproduce

I don't know how to create such an app, ours is rather complicated.

Link to public reproduction project repository

No response

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.71 SR7.1 (on revising history, it might be that no version wint .net 8 would have passed google certification)

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Nope.

Relevant log output

No response

@PureWeen
Copy link
Member

@PureWeen PureWeen transferred this issue from dotnet/maui Oct 18, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Oct 18, 2024
@skolumban-ex
Copy link
Author

Can you attach a logcat file with your crash? https://learn.microsoft.com/en-us/xamarin/android/deploy-test/debugging/android-debug-log?tabs=windows

Unfortunately I am not even able to reproduce the issue. It is only the Play store that is rejecting our app updates because of crash on startup. And I receive the logs in Sentry from the runs they are having during the verification procedure.

@skolumban-ex skolumban-ex changed the title Failed resolution of: Landroidx/activity/OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1; after updating to 8.0.91 from 8.0.71 Failed resolution of: Landroidx/activity/OnBackPressedDispatcher$Api34Impl$createOnBackAnimationCallback$1; after updating to 8.0.91 Oct 21, 2024
@skolumban-ex
Copy link
Author

skolumban-ex commented Oct 21, 2024

At the moment my best guess is around API versions.

The application is targeting API level 34, and it is also set as minimum API level.

However the Sentry logs say that the app is being tested on an Android 11 phone, SDK level 30.

Image

I have filed a request to let google clarify this.

Based on the Api34Impl name, this is probably an OS level version issue.

@jpobst
Copy link
Contributor

jpobst commented Oct 29, 2024

When you test locally, are you only testing by running it from VS in the debugger?

Have you tried testing locally with the final package you are uploading to Google Play?

The application is targeting API level 34, and it is also set as minimum API level.

If they are able to install it on an Android 11 device then I suspect a minimum level of API-34 has not been set. I believe this is controlled by the <SupportedOSPlatformVersion> property in the .csproj, which defaults to 21.

You may want to try running your app on an Android 11 emulator and see if you see the same crash.

@jpobst jpobst added Area: App+Library Build Issues when building Library projects or Application projects. need-info Issues that need more information from the author. and removed needs-triage Issues that need to be assigned. labels Oct 29, 2024
@skolumban-ex
Copy link
Author

@jpobst I see that the supportedOSPlatformVersion was set correctly.

This was the line in the csproj at the time of the issue:
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">34.0</SupportedOSPlatformVersion>

In the meantime I posted the question to Google as well, how is it that they install the app to OS versions that are not supported.

https://support.google.com/googleplay/android-developer/thread/302593365/play-console-uses-wrong-os-version-for-app-verification-according-to-sentry?msgid=302653664#

I lowered the version to support Android 11 as well, and danced around a bit in the app, so it does not crash on Android 11. That did the trick for me.

By the way, at the time of the issue, the app would not deploy to an Android 11 emulator (as is expected).

So from my point of view the issue is not on maui end, but at Google, as they seem to deploy the app to OSes that are not declared supported by the app.

Ill come back, if there is any updates from their end.

@dotnet-policy-service dotnet-policy-service bot added need-attention A xamarin-android contributor needs to review and removed need-info Issues that need more information from the author. labels Oct 30, 2024
@rezamohamed
Copy link

I have the same issue, it seems to be mostly during Googles app review only.

ClassNotFoundException. androidx.activity.OnBackPressedDispatcher

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">33.0</SupportedOSPlatformVersion>

Sentry is showing that the device is a OnePlus8Pro, Android 11

@skolumban-ex
Copy link
Author

@rezamohamed if you lower the min supported sdk version to 30, the issue will most likely go away. It did the trick for me.

@rezamohamed
Copy link

rezamohamed commented Nov 5, 2024

Thanks for that workaround. I forget the actual reason now, but I had to set min to 33 (maybe it was Androids new requirement).

Ideally, I’d like to figure out the root cause so I can nip it in the bud.

Update: found it

Starting August 31 2024:

New apps and app updates must target Android 14 (API level 34) or higher to be submitted to Google Play; except for Wear OS and Android TV apps, which must target Android 13 (API level 33) or higher.

Existing apps must target Android 13 (API level 33) or higher to remain available to new users on devices running Android OS higher than your app's target API level. Apps that target Android 12 (API level 31) or lower (Android 10 (API level 29) or lower for Wear OS and Android 11 (API level 30) or lower for Android TV), will only be available on devices running Android OS that are the same or lower than your app's target API level.

@skolumban-ex
Copy link
Author

skolumban-ex commented Nov 13, 2024

@rezamohamed This update is about the target API level. The minimum API level can be lower. So you can have API level 34 as target, and 30 as minimum SDK level.

@jonathanpeppers
Copy link
Member

SupportedOSPlatformVersion defaults to 21, so this problem only occurs if you set it to 33? IMO it's probably not the best idea to choose this as your app only runs on 33% of devices according to Android Studio:

Image

Can someone make a small sample that shows the issue here? Thanks!

@jonathanpeppers jonathanpeppers added need-info Issues that need more information from the author. and removed need-attention A xamarin-android contributor needs to review labels Nov 18, 2024
Copy link

Hi @skolumban-ex. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App+Library Build Issues when building Library projects or Application projects. need-info Issues that need more information from the author.
Projects
None yet
Development

No branches or pull requests

6 participants