From 3.15 release:
Android SDK Tools 25.3.0+ removes ant script and android tool, which leads to that cocos command can not generate apk files with Eclipse projects(proj.android). Currently, cocos command will do nothing if using SDK Tools 25.3.0+, you can use these two methods to fix it:
- copy tools folder from old Android SDK version
- use Android Studio to build the app
It seems google doesn’t want developers continue to use Eclipse to develope Android applications, so i suggest to switch to use Android Studio.
I used first option 1 before, so copied tools
folder from old SDK(25.2.5).
With this solution I can generate pre-built libs for android using:
cocos gen-libs -p android --ap android-19 --app-abi x86:armeabi-v7a
And later configure project in android studio to compile my game really fast. Worked well.
But today I wiped all android folder with any SDK’s, tool and other files, just was needed some free space on my SSD drive.
After all, later I re-installed all(re-downloaded all in android studio) with the latest versions.
For sure, finally I replaced tools
as I did before. After that I executed command to generate pre-built libs and it completed successfully.
But when I’ve tried to build my game in android studio, with familiar setup, without any changes in my code(also it worked perfect for iOS currently) I got the following errors:
Any ideas how to fix it? Again, on iOS all works perfect, with pre-build libs too.
I have:
build.gradle(Module: MyGame):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.test"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
ext {
cocospath = "/Volumes/MacData/Cocos2d-x"
}
externalNativeBuild {
ndkBuild {
targets "MyGame"
arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk"
arguments "-j" + Runtime.runtime.availableProcessors()
abiFilters "armeabi-v7a"
//abiFilters "x86"
//abiFilters "x86", "armeabi-v7a"
}
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
}
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':libcocos2dx')
}
task cleanAssets(type: Delete) {
delete 'assets'
}
task copyAssets(type: Copy) {
from '../../Resources', '../../MyGame.spritebuilder/Resources_iOS'
into 'assets'
}
clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets
build.gradle(Module: libcocos2dx):
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
sourceSets.main {
aidl.srcDir "../java/src"
java.srcDir "../java/src"
manifest.srcFile "AndroidManifest.xml"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: '../java/libs', include: ['*.jar'])
}
proj.android-studio/app/jni/Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../../Classes/AppDelegate.cpp \
and all other like
../../../Classes/FmodManager.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_SHARED_LIBRARIES := fmod
include $(BUILD_SHARED_LIBRARY)
$(call import-add-path, $(LOCAL_PATH)/../../../Classes/FMOD)
$(call import-module,./android)
$(call import-module,./prebuilt-mk)
proj.android-studio/app/jni/Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
APP_ABI := armeabi-v7a x86
#APP_STL := c++_static stlport_shared
#NDK_TOOLCHAIN_VERSION=clang
ifeq ($(NDK_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif
Also:
Looking also for option 2.
I want just to generate pre-built libs for android with all latest updates…
I don’t get how to use android studio to build pre-built libs? Or any other way?
UPD: