Some log:
Choreographer: Skipped 11 frames! The application may be doing too much work on its main thread.
WindowManager: Failed looking up window
cocos2d-x debug info: cocos2d: fullPathForFilename: No file found at script/jsb_prepare.js. Possible missing file.
cocos2d-x debug info: cocos2d: fullPathForFilename: No file found at script/jsb_prepare.jsc. Possible missing file.
cocos2d-x debug info: cocos2d: fullPathForFilename: No file found at script/jsb_prepare.js. Possible missing file.
ScriptingCore.cpp: ScriptingCore:: compileScript fail:script/jsb_prepare.js
cocos2d-x debug info: JS: (string):1:TypeError: cc.Class is undefined
Use classpath ; âcom.android.tools.build:gradle:3.1.4â . in gradle setting dependency
and
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip . in gradle-wrapper-properties
when you use above property your âbuildToolsVersionâ will be set to â27.0.3â
Iâm using cocos2d 3.17.1
I fixed it using your solution and added two variables to reduce copy-paste code.
android.applicationVariants.all { variant ->
def project_root_folder = "${buildDir}/../../../../.."
def dest_assets_folder = "${buildDir}/intermediates/merged_assets/${variant.dirName}/merge${variant.dirName}Assets/out"
// delete previous files first
delete dest_assets_folder
variant.mergeAssets.doLast {
copy {
from project_root_folder + "/res"
into dest_assets_folder + "/res"
}
copy {
from project_root_folder + "/src"
into dest_assets_folder + "/src"
}
copy {
from project_root_folder + "/frameworks/cocos2d-x/cocos/scripting/js-bindings/script"
into dest_assets_folder + "/script"
}
copy {
from project_root_folder + "/main.js"
from project_root_folder + "/project.json"
into dest_assets_folder
}
// compile the scripts if necessary
def compileScript = (variant.name.compareTo('release') == 0)
if (project.hasProperty('PROP_COMPILE_SCRIPT')) {
compileScript = (PROP_COMPILE_SCRIPT.compareTo('1') == 0)
}
if (compileScript) {
compileJS(dest_assets_folder, dest_assets_folder)
}
}
}
I was not able to solve warning:
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
i changed mergedAssets.doLast to mergedAssetsProvider.doLast and it is saying could not find method doLast, did anyone else get this when trying to change it ?