If you believe your Android phone or tablet has a virus then the good news is it's really easy to delete. Here's how to remove a virus from Android. Also see: Best Android antivirus 
First of all, it's worth pointing out that it's unlikely that your Android phone or tablet has a virus. What you're more likely to be seeing is an ad that wants to convince you Android is infected and you need to download an app, or a dodgy pop-up, or perhaps your device is just misbehaving. But viruses for Android do exist. If you're sure your device has one, here's how to remove it. 
All Android viruses are delivered via apps installed on your device, so if your phone or tablet doesn't already have a virus, the best way to avoid it getting one is to never install software outside of the Google Play app store. Open your Settings menu, look for the Security option, then ensure the option for Unknown Sources (allow installation of apps from unknown sources) is disabled. Also see: Security Advisor 
If you're determined to install an app from outside Google Play, do your research. Check its permissions (does a video player really need to see your contacts?), look online for reviews and have a good look at the developer's site to see what else it offers. 
You can also install an antivirus app, and plenty of free Android antivirus apps are available that are able to detect and remove malicious apps, for example 360 Mobile Security, Avast and Lookout. These all include an app scanner that will seek out anything dodgy, but note that these apps can also trigger false-positives - reporting an app you've been using for months as malware when you know it's fine. In most cases you can simply ignore these alerts. 
If you believe you already have a virus on your Android phone or tablet - perhaps one that is resisting your attempts to uninstall the associated app or even let you bypass the lock screen - a factory reset will remove it, returning your device to its out-of-the-box state. But doing so also means you'll lose everything on your phone that's not backed up. Instead, follow the below steps to remove a virus from Android.

How to remove a virus from Android 

Step 1. Put your phone or tablet into Safe mode. This prevents any third-party apps running, including any malware. On many devices you can press the power button to access the power off options, then press and hold Power off to bring up an option to restart in Safe mode. If this doesn't work for your device then you should Google 'How to put [your model name] into Safe mode' and follow the instructions. When in Safe mode you'll see 'Safe mode' at the bottom left of the screen.
How to remove a virus from Android: Delete a virus from your Android phone or tablet 

Step 2. Open your Settings menu and choose Apps, then make sure you're viewing the Downloaded tab. If you don't know the name of the virus you think has infected your Android phone or tablet, go through the list and look for anything dodgy-looking or that you know you haven't installed or shouldn't be running on your device.  
How to remove a virus from Android: Delete a virus from your Android phone or tablet

Step 3. Tap on the malicious app (clearly it won't be called 'Dodgy Android virus', this is just an illustration) to open the App info page, then click Uninstall. In most cases, this is all you need to do to remove the virus, but occasionally you might find the Uninstall button is greyed out. This is because the virus has given itself Device administrator status. 
How to remove a virus from Android: Delete a virus from your Android phone or tablet

Step 4. Exit the Apps menu and tap on Settings, Security, Device Administrators. Here you'll find a list of any apps on your phone or tablet with administrator status. Simply untick the box for the app you want to remove, then tap Deactivate on the next screen. You should now be able to return to the apps menu and remove that app. 
How to remove a virus from Android: Delete a virus from your Android phone or tablet

Step 5. With the virus now off your Android phone or tablet, all you need to is restart the device to take it out of Safe mode. Now that it's working correctly it's a good time to back up whatever important data you have stored on the device, and install an Android antivirus app to protect you from any future viruses that come your way.