解决CocosCreator打包Android时的“ no rule to make target
cocos2djs ” 问题
CocosCreator Android building troublesh...
Android env setup and building panel
First make sure that you have working "Android SDK+NDK" combination setup in the "overall CocosCreator Settings". Second, mind some settings in the build panel. When building for "Android",** shall I use "default" or "link" template?** Actually either works, but you should tailor-make the "build-template folder" for the chosen template.
Use a matching Gradle version
Make sure that you use "Matching CocosCreator version & Gradle version", e.g. "CocosCreator or v2.1.3 only works with Gradle-4.x". Note that "AndroidStudio" could use a different Gradle version than that specified by "GradleWrapper", to be sure about the pipeline you can always build with your "GradleWrapper".
What if you didn't use a matching Gradle version
If due to an unknown reason your built Android project just comes up with an unmatching Gradle version, you might get a "no rule to make target
Such problem could occur after blind clicked "upgrade" in AndroidStudio, which may overwrite your "project.android-studio/build.grade".
Another case showed that the same error might also show up after a newly created "HelloWorld" project (from CocosCreator v2.1.3 welcome pane, no build-template customization, no CocosCreator folder src code customization, even without opening AndroidStudio). In this case the resulted "proj.android-studio/build.gradle" uses a "com.android.tools.build:gradle:4.x.x (the
AndroidGradlePlugin)", and the automatically chosen "GradleWrapper version" will be "5.x" (the actual
There were some build warning like "deprecared variant.mergeAssets", not sure whether it's relevant to this issue.
You cannot just change the "distributionurl" in "proj.android-studio/gradle/wrapper/gradle-wrapper.properties" to use "another Gradle version", which will only result in yet some other building issues.
The currently working solution is to create a "Gradle version constraint build-template file", as shown in the screenshot below, to specify version constraints.
Building from CLI
To see explicit warnings of the use of "obsolete APIs".
bashshell> /path/to/frontend/build/jsb-link/frameworks/runtime- src/proj.android-studio (master)
$ ./gradlew build -Pandroid.debug.obsoleteApi=true --warning-mode all