Can't compile cocos2d-x for android studio

HI
When i try to import cocos game into android studio i get gradle build error, because i dont have android-22 in sdk folder. I tried changing every value of android 22 in gradle files but it didnt work. I also tried compiling it explicitly saying it should be api 25 using command
cocos compile -p android --android-studio --ap android-25
it gets error:

 * What went wrong:
  A problem occurred configuring project ':game1'.
> A problem occurred configuring project ':libcocos2dx'.
   > failed to find target with hash string 'android-22' in: /home/redy/Android-SDK

What am i doing wrong? I would really appreciate help.

Maybe you forgot to subtitute the occurences in libcocos2dx/build/build.gradle.

Okay, i changed api in lobcocos2dx/build/build.gradle in cocos files, created new game and i got the same error but without the part about libcocos2dx

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':game1'.
> failed to find target with hash string 'android-22' in: /home/redy/Android-SDK

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Make sure you have android-22 in /home/redy/Android-SDK/platform/android-22

For every new game project, you need to change both the sdk value in game1/app.build.gradle and libcocos2dx/build/build.gradle.

Gradle need both of them correct to work.

Make sure both your project’s gradle and cocos2dx’s gradle is using the same Android SDK version and also make sure you have downloaded the specified Android SDK version into your computer

Thanks to all of you! I didn’t know both files were suposed to be changed. Now everything works correctly. I can start my adventure with cocos :slight_smile: