简体   繁体   中英

Failed to Deploy Android Xamarin Forms Application After Adding Splash Screen

For a couple days I tied to implement the splash screen on Android Xamarin Forms Application, I tied many approaches but all failed in the same way, The application before adding the splash screen is working fine, After adding the splash screen i get this error message

3>------ Deploy started: Project: NoorAlEman.Android, Configuration: Debug Any CPU ------ 3>Error: Cancelled ========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

sometime the application run without showing the splash screen for one time only if i delete "bin" and "obj" folder and rebuild the solution and most of other time it keeps showing the same error message. I am sure about adding all files using visual studio 2019 interface, also all files have Build Action: AndroidResource Copy to output directory: Do not copy "Also i tried to make it as copy always" Custom tools: I tried to leave it empty and other times i set to "MSBuild:UpdateGeneratedFiles" Other thing i done is to set the MainLauncher to false in the manactivity.cs and setting it to true in the splashsctivity.cs I tried these tutorials and all ended up showing the same error

(1) https://docs.microsoft.com/en-us/xamarin/android/user-interface/splash-screen

(2) https://progrunning.net/best-way-to-create-a-splash-screen-in-xamarin-forms-android-project/

(3) http://ebubekirsezer.com/en/xamarin-forms-splash-screen/?unapproved=11607&moderation-hash=67d1307ecdd13ca8e5b0acceae43d22d#comment-11607

Please do you have any suggestion that might resolve this issue. Thank you in advance M. Mazin

What I did was to create a new activity, say SplashActivity with the following attributes [Activity(MainLauncher = true, Theme = "@style/MainTheme.Splash", NoHistory = true)] , where the Theme would be an image, or whatever you want your splashscreen to be. Then inside you just start the main activity of your application, something like this:

protected override void OnResume()
{
    base.OnResume();
    StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}

Don't forget to remove the MainLauncher attribute from the MainActivity.

Hope it helps

For me the only solution was: -rebuilding the project -closing and reopening VS -disconnecting and reconnecting my mobile device

I don't know where this error comes from, and it's a real pain, but this way you can at least keep testing your app until there comes an update which fixes it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM