I'm trying to build my cocos project to android.
At first, I ran the following command:
cocos run -s {my_project_path} -p android
And I got errors of packages and symbols that weren't found, here is the first error:
error: package org.apache.http does not exist
import org.apache.http.Header;
and after the list of items that weren't found:
BUILD FAILED
......\AppData\Local\Android\sdk\tools\ant\build.xml:597: The following error occurred while executing this line:
......\AppData\Local\Android\sdk\tools\ant\build.xml:716: The following error occurred while executing this line:
......\AppData\Local\Android\sdk\tools\ant\build.xml:730: Compile failed; see the compiler error output for details.
I've read that it can be because my android project version was 23.
So I edited the version field in the android.properties file to 22
and ran the next command:
cocos run -s {my_project_path} -p android --ap android-22.
The first build output lines are saying it uses the android 22 api, but in the middle of the build, for some reason it starts to use version 23 and I receive the same errors above.
Did anybody have those errors?
Thank you, Ben
That's because
HttpClientisn't supported in android 6.0:https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html
You can read details here:
https://stackoverflow.com/a/32153434/1264375
Anyway easiest way to fix this is to change api level to 22 (as you said). But you have to do it in AndroidManifest (in my case I'm using api level 19):
Also you have to change api level in eclipse project settings in Android section.