In my case, I downloaded version 22 of Android M and Android 5.1.1 using Android Studio 1.2.1.1, but when I try to make Hello World, the same error showed me
So, the solution for me was doing a right click in the application, as shown below, and select "Open module settings"

then you have 2 options. I changed both with the latest version that I had.
Compile SDK version for Lollipop API 21

and Build Tools version up to 21.1.2

Finally, clean the project and build
UPDATED
To get Android Studio 1.3, follow these steps:
- Open the Preferences window by choosing File> Preferences.
- Choose Appearance & Behavior> System Settings> Updates.
- In the Updates panel, select the Automatically check for updates for: Canary Chanel option .
- In the Updates panel, select Check Now to check the latest version of Canary. Download and install the assembly when prompted.
Then you will have something similar to upgrade your Androud Studio to version 1.3, and with this you can test Android M

Update: the real reason
This error occurs when the SDK, Build Tools, and Gradle Plugins versions do not match (in terms of compatibility). Solutions are checked if you use their latest versions. Gradle plugins are placed in the build.gradle of the project, and other versions are on the build.gradle module. For example, for SDK 23 you should use Build Tools 23.0.1 and Gradle plugins version 1.3.1.
Jorge Casariego May 29 '15 at 3:25 2015-05-29 03:25
source share