Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apk not have asssets folder Or When running, have error: "TypeError: cc.Class is undefined" (cocos2dx v3.17 js project, run with gradle version 4.6 and android plugin version 3.2.1) #19301

Closed
zerominh opened this issue Jan 15, 2019 · 2 comments · Fixed by #19679
Milestone

Comments

@zerominh
Copy link

zerominh commented Jan 15, 2019

Reason: in gradle 4.6, merge assets is changed to folder merged_assets, not in assets folder
I fixed it with modify build.gradle file:
copy {
println("copy " + Paths.get("${buildDir}", "/../../../../../res") + " ===> " + Paths.get("${buildDir}",
"/intermediates/merged_assets/${variant.dirName}/merge${variant.dirName}Assets/out/res"))
// from "${buildDir}/../../../../../res"
// into "${buildDir}/intermediates/assets/${variant.dirName}/res"
from(Paths.get("${buildDir}", "/../../../../../res"))
into(Paths.get("${buildDir}", "/intermediates/merged_assets/${variant.dirName}/merge${variant.dirName}Assets/out/res"))
}
Another "copy {}" lines and "delete" line is modified similarly

@drelaptop drelaptop added this to the next milestone Jan 15, 2019
@ghost
Copy link

ghost commented May 8, 2019

android.applicationVariants.all { variant ->
    def project_root_folder = "${buildDir}/../../../../.."
    def dest_assets_folder = "${buildDir}/intermediates/merged_assets/${variant.dirName}/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)
        }
    }
}

@minggo
Copy link
Contributor

minggo commented May 8, 2019

I don't quite understand this issue, could some one send a PR? Thanks.

@minggo minggo modified the milestones: 3.17.2, next May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants