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

ActivityNotFoundException when attempting to use a new Activity and other issues with outdated AndroidManifest.xml in projects configured to use Enhanced Fast Deployment #2608

Open
brendanzagaeski opened this Issue Jan 11, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@brendanzagaeski
Copy link
Member

brendanzagaeski commented Jan 11, 2019

Steps to Reproduce

  1. Create a new Android application project.

  2. Add the following lines to the .csproj file to enable Enhanced Fast Deployment:

    <PropertyGroup>
        <AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>
    </PropertyGroup>
  3. Add an additional Activity subclass to the project, similar to:

    public class SecondActivity : Activity {
    	protected override void OnCreate (Bundle savedInstanceState)
    	{
    		base.OnCreate (savedInstanceState);
    		SetContentView (Resource.Layout.activity_main);
    	}
    }
  4. Choose Debug > Start Debugging to build, deploy, and start debugging the app.

  5. Choose Debug > Stop Debugging.

  6. Add an [Activity] attribute to SecondActivity to make the build process generate an entry for it in AndroidManifest.xml.

  7. Add a line to start the new activity from the MainActivity.OnCreate() override via an Intent:

    StartActivity (typeof (SecondActivity));
  8. Choose Debug > Start Debugging.

Actual Behavior

UNHANDLED EXCEPTION:
Android.Content.ActivityNotFoundException: Unable to find explicit activity class {AndroidApp1.AndroidApp1/md559d7fc296fc238aa7bec92ba27f2cb33.SecondActivity}; have you declared this activity in your AndroidManifest.xml?

The new activity cannot be started because the AndroidManifest.xml file has not been updated on-device. Indeed the timestamps on the .apk files in the bin\ directory show the time of the initial build from step 4 rather than the new build from step 8.

It looks like the issue might be that the _BuildApkFastDev target doesn't have $(IntermediateOutputPath)android\AndroidManifest.xml as an input, so the target is skipped:

2>Target "_BuildApkFastDev" in file "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Common.Debugging.targets" from project "c:\Temp\AndroidApp1\AndroidApp1\AndroidApp1.csproj" (target "_CopyPackage" depends on it):
2>Skipping target "_BuildApkFastDev" because all output files are up-to-date with respect to the input files.
2>Input files: C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Java.Interop.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.1\Mono.Android.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Core.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Xml.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Net.Http.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Runtime.Serialization.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.ServiceModel.Internals.dll;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\Mono.Security.dll;c:\Temp\AndroidApp1\AndroidApp1\obj\AndroidApp1.csproj.nuget.g.props;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin\Microsoft.Xaml.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Microsoft.Common.targets\ImportAfter\Microsoft.NET.Build.Extensions.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.ConflictResolution.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.DefaultPackageConflictOverrides.targets;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Microsoft\NuGet\16.0\Microsoft.NuGet.targets;c:\Temp\AndroidApp1\AndroidApp1\obj\AndroidApp1.csproj.nuget.g.targets;obj\Debug\81\build.props;obj\Debug\81\adb.props
2>Output files: obj\Debug\81\android\bin\AndroidApp1.AndroidApp1.apk
2>Done building target "_BuildApkFastDev" in project "AndroidApp1.csproj".

DiagnosticMSBuildOutput.zip

Expected Behavior

If I disable Enhanced Fast Deployment and go back to classic Fast Deployment, the _BuildApkFastDev target does build in this scenario, and the new activity starts successfully.

Version Information

Microsoft Visual Studio Enterprise 2019 Int Preview
Version 16.0.0 Preview 2.0 [28509.60.d16.0]
VisualStudio.16.IntPreview/16.0.0-pre.2.0+28509.60.d16.0
Microsoft .NET Framework
Version 4.7.03056

Xamarin.Android SDK 9.1.103.6 (HEAD/1127dc3a)

@brendanzagaeski

This comment has been minimized.

Copy link
Member

brendanzagaeski commented Jan 11, 2019

/cc @dellis1972 for a quick look when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment