Small problems with cocos v. 3.17.2 compiler

I code on C++ and compile on Windows 7 for Android in command prompt.

I used last stable cocos2d-x v. 3.16 with sdkbox 2.3.17.7
Now looks like I succeed to migrate one my project (debug version) to cocos v. 3.17.2 with sdkbox 2.4.3.3.
Installed packages: admob facebook iap sdkboxads gpg googleplayservices (v2.4.3.3)

First problem: I lost a lot of time searching for the code crashing my app. Here it is:

bool HelloWorld::init()
{ 
	// a lot of code
	f();
	return true;
}

int HelloWorld::f()
{
//	return 0; // so - no proper return; So, I need compiler not to crash my app and/or to prompt me about bug at this row;
}

Old cocos2d-x 3.16 command prompt compiler generated app which not crashed with this code. But with newer it crashes.

That error log:

I DEBUG   :     r0 61a8a9a8  r1 61a8a9a8  r2 00000008  r3 601a750c: /system/bin/debuggerd
D ADB_SERVICES:  closing because is_eof=1 r=-1 s->fde.force_eof=0: /sbin/adbd
I DEBUG   :     r4 1da00001  r5 5f32a228  r6 1b979e91  r7 609bc910: /system/bin/debuggerd
W ADB_SERVICES: entered. LS(95175) fd=20: /sbin/adbd
I DEBUG   :     r8 609bcad8  r9 608bef14  sl 5bb3c148  fp 609bcaec: /system/bin/debuggerd
I DEBUG   :     ip 608671a0  sp 609bc6c4  lr 600dc63b  pc 600dc8aa  cpsr 60070030: /system/bin/debuggerd
I DEBUG   : : /system/bin/debuggerd
I DEBUG   : backtrace:: /system/bin/debuggerd
I DEBUG   :     #00  pc 0028a8aa  /data/app-lib/org.cocos2dx.t2-1/libMyGame.so (HelloWorld::f()+7): /system/bin/debuggerd
I DEBUG   :     #01  pc 0028a637  /data/app-lib/org.cocos2dx.t2-1/libMyGame.so (HelloWorld::init()+1334): /system/bin/debuggerd

I am_crash: [673,0,org.cocos2dx.t2,8961606,Native crash,Illegal instruction,unknown,0]: system_server
V Provider/Settings:  from settings cache , name = dropbox:SYSTEM_TOMBSTONE , value = null: system_server
V Provider/Settings:  from settings cache , name = dropbox:data_app_native_crash , value = null: system_server

I am_finish_activity: [0,1122386560,77,org.cocos2dx.t2/org.cocos2dx.cpp.AppActivity,crashed]: system_server

Second problem: then I replace code file with its old version – looks like compiler do not recompile it (because it is not new).
Update: I’ve succeed to build release version only after the only change: updating date+time of all files in “Classes” to current.

Third problem: what about pre-build libraries for Android and Win32 (Visual Studio)? Had someone succeed?

Could someone recommend some settings for the new command_prompt compiler? (Thank you. It is NOT urgent)

@yinjimmy can help

My suggestion is clean and re-compile the whole project.

and cocos command has some difference between 3.16 and 3.17:

cocos 3.16 uses ndk-build as default but 3.17 uses cmake.

you can try:

cocos run -p android --build-type ndk-build

Thanks,

1 Like

Having debug build I could not create release build.
I’ve succeed to build the release version only after the only change : updating date+time of all files in “Classes” to current.
"clean and re-compile the whole project" – too long.

plz try

cocos run -p android --build-type ndk-build

Thanks, you offered that yesterday, so I updated my release-build.bat file to:

cls
cocos compile -p android --build-type ndk-build -m release

…and I use it. So, now native code always compiles.
Also:

  1. I afraid I can’t reproduce that bug, because I succeed to build a release version.
  2. Is it a big difference between ‘run’ and ‘compile’? What is better?
  3. What if I uncomment #PROP_BUILD_TYPE=ndk-build in proj.android\gradle.properties?

The crash you experienced is not a bug. It happened because you didn’t do a clean/rebuild, you simply replaced certain source files, and the compiler didn’t pick up the changes. Mixing up generated object files like this would cause the most random issues. The fact that you had to ‘touch’ the files (updating their date/time stamp) to force the compiler to do a rebuild, which resulted in the crash no longer happening, proves that point. You really should have done a clean/rebuild instead.

That’s not a valid reason to avoid doing a clean and rebuild, and when you don’t, as you experienced, you end up with undefined behavior, especially when you change something so significant as a new version of Cocos2d-x.

3 Likes

" clean and re-compile the whole project"

Does clean means to delete whole proj.android\app\build folder or is there another way (some console command)?

Clean deletes whatever it needs to delete in order to rebuild the project, if that’s what you’re asking.

Just use gradlew for it:

gradlew clean

More info about building from the command line using Gradle is here.

2 Likes

How should I do clean or recompile via command prompt (on Windows 7)?

'>gradlew' is not recognized as an internal or external command

>gradle clean executes, but says: Task 'clean' not found in root project 'my_project'

>gradle tasks says:

Build Setup tasks
-----------------
init - Initializes a new Gradle build. [incubating]
wrapper - Generates Gradle wrapper files. [incubating]

Have you tried building your application with Android Studio first to check if it actually works? If it doesn’t work via Android Studio, then you’ll have to hunt down the reasons why. If it does work, then there is little reason for it to not work via the command line either.

One thing to check for, if you’re building with the Windows CLI, then the path to the location of gradlew.bat may be missing from the environment path settings, so check that first. There should be an entry like this in there:

C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle\wrapper

That is where gradlew.bat exists (on 64bit systems).

EDIT: gradlew.bat seems to also be in the [your project]/proj.android folder too, so check it out to see if it works for you.

Oh yes, of course! Then (running gradlew.bat from myProject folder):

c:\Develop\myProject>proj.android\gradlew tasks

> Task :tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'myProject'.
components - Displays the components produced by root project 'myProject'. [incubating]
dependencies - Displays all dependencies declared in root project 'myProject'.
dependencyInsight - Displays the insight into a specific dependency in root project 'myProject'.
dependentComponents - Displays the dependent components of components in root project 'myProject'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'myProject'. [incubating]
projects - Displays the sub-projects of root project 'myProject'.
properties - Displays the properties of root project 'myProject'.
tasks - Displays the tasks runnable from root project 'myProject'.

To see all tasks and more detail, run gradlew tasks --all

To see more detail about a task, run gradlew help --task <task>


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

so it is not possible to execute task “clean”:

c:\Develop\myProject>proj.android\gradlew clean

FAILURE: Build failed with an exception.

* What went wrong:
Task 'clean' not found in root project 'myProject'.

Alas I do not use Android Studio, only Visual Studio for now.
Thank you.

In your app, do you have the following:

[your app]/proj.android/build.gradle:

dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
}

and in [your app]/proj.android/gradle/gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

This is with Android Studio 3.4.1. The gradlew clean command works when run inside the Android Studio terminal, so I’m at a loss as to why it’s not working for you.

1 Like