NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
519 stars 135 forks source link

__runtimeVersion equals 0.0.0.0 in release builds since @nativescript/android 8.2.3 #1715

Closed sebj54 closed 2 years ago

sebj54 commented 2 years ago

Environment

Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug

__runtimeVersion equals 0.0.0.0 in release builds only. It has the expected value in debug builds.

The problem is present since 8.2.3. It works as expected with @nativescript/android 8.2.2

To Reproduce

I made a sample project so it will be easier to reproduce the bug. It is basically a fresh Vue project created with ns create, I only replaced the message shown on home screen by __runtimeVersion.

git clone https://github.com/sebj54/ns-debug-runtime-version.git
cd ns-debug-runtime-version
ns run android --release

If you want to see it working with @nativescript/android 8.2.2

git checkout 8.2.2
ns clean
ns run android --release

You can also see that it works fine on debug builds with ns debug android.

Expected behavior

__runtimeVersion should equal 8.2.4 and not 0.0.0.0

Sample project

https://github.com/sebj54/ns-debug-runtime-version

Additional context

Feel free to reach me if something is unclear or if you want me to test anything locally, I'll be glad to help.

sebj54 commented 2 years ago

I digged deeper and found that the problem is caused by the setPackageVersion gradle task: https://github.com/NativeScript/android-runtime/blob/905d96ea3ac2bc8d2be8afea7d48067f2f733679/test-app/runtime/build.gradle#L167-L180

It is called too late and the modified Version.h file is not used to build the package.

So I was wrong in my first assumption: the 8.2.3 version didn't introduce the bug, but it was the first version to be packaged with an unmodified Version.h file.

The problem was also present in 8.2.2 version, because the demo app shows 8.2.1. This version may have been built on a computer which had also built the previous version.

Now I'm trying to figure out how to fix the problem but I'm not used to write Gradle files. Any help would be very appreciated :)