Xamarin-android: Java.Lang.RuntimeException: 'Unable to resume activity {xxx.MainActivity}: java.lang.IllegalStateException: No activity'

Created on 13 Aug 2020  路  3Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

This is a random bug, this just happened today and is my first time experiencing it. I cloned a working copy of my private project from a git. repo. _(My app has a splash screen that will then redirect to MainActivity.cs)_ It's working fine when I disable the redirection to MainActivity.

P.S. This only happens in debug mode.

  1. Run a Xamarin.android app in debug mode in an actual device.

    Expected Behavior

The app will run smoothly

Actual Behavior

App Crashes and throws the error below:
image

Version Information

Microsoft Visual Studio Community 2019
Version 16.7.1
VisualStudio.16.Release/16.7.1+30406.217
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

ASP.NET and Web Tools 2019 16.7.532.28833
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services 16.1.0.2035807+72d099b977d3a85e65fa3b0614ca8cfc803fef02
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019 16.7.532.28833
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.7.532.28833
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.7.532.28833
Azure Functions and Web Jobs Tools

C# Tools 3.7.0-6.20375.2+34202cc2f3e869fd70a26d8237f4552cf9e192cf
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30701.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.79+ge3567815aa.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Mono Debugging for Visual Studio 16.7.5 (112c7bc)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.7.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62008.03130
Microsoft SQL Server Data Tools

TypeScript Tools 16.0.20702.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.7.0-6.20375.2+34202cc2f3e869fd70a26d8237f4552cf9e192cf
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.10.0.0 for F# 4.7 16.7.0-beta.20361.3+3ef6f0b514198c0bfa6c2c09fefe41a740b024d5
Microsoft Visual F# Tools 10.10.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview) 1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Foo 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 16.7.000.440 (d16-7@358f3c6)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.7.0.495 (remotes/origin/d16-7@79c0c522c)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.7.85 (1bcbbdf)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 11.0.0.3 (d16-7/aca845b)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

Xamarin.iOS and Xamarin.Mac SDK 13.20.2.2 (817b6f72a)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Log File

08-13 14:58:02.373 E/AndroidRuntime(29891): FATAL EXCEPTION: main
08-13 14:58:02.373 E/AndroidRuntime(29891): Process: com.xxx, PID: 29891
08-13 14:58:02.373 E/AndroidRuntime(29891): java.lang.RuntimeException: Unable to resume activity {com.xxx/crc64ad71c287ecbaf998.MainActivity}: java.lang.IllegalStateException: No activity
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3866)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3898)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1839)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.os.Handler.dispatchMessage(Handler.java:106)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.os.Looper.loop(Looper.java:201)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.ActivityThread.main(ActivityThread.java:6864)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at java.lang.reflect.Method.invoke(Native Method)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
08-13 14:58:02.373 E/AndroidRuntime(29891): Caused by: java.lang.IllegalStateException: No activity
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentManagerImpl.moveToState(:1837)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(:3269)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentManagerImpl.dispatchResume(:3241)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentController.dispatchResume(:223)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentActivity.onResumeFragments(:538)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v4.app.FragmentActivity.onPostResume(:527)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.support.v7.app.AppCompatActivity.onPostResume(:172)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.Activity.performResume(Activity.java:7438)
08-13 14:58:02.373 E/AndroidRuntime(29891):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3858)
08-13 14:58:02.373 E/AndroidRuntime(29891):     ... 11 more

Most helpful comment

PROGUARD ISSUE

I disabled the code shrinker for debug mode _(I'm not sure why it's enabled in the first place)_ and set the Dex compiler back to DX from D8. That fixed this issue.

All 3 comments

PROGUARD ISSUE

I disabled the code shrinker for debug mode _(I'm not sure why it's enabled in the first place)_ and set the Dex compiler back to DX from D8. That fixed this issue.

I disabled the code shrinker for debug mode _(I'm not sure why it's enabled in the first place)_ and set the Dex compiler back to DX from D8. That fixed this issue.

thanks, that also helped me (VS2019 16.7.1)

This helped me as well !

Was this page helpful?
0 / 5 - 0 ratings