Skip to content

Android ExampleApp's jni build.sh doesn't handle relative pathes for LOG_FILE #2741

@muzso

Description

@muzso

Describe the bug

The <sdk>/examples/android/ExampleApp/app/src/main/jni/build.sh script redirects various command output into $LOG_FILE, but meanwhile it changes the current working directory multiple times.

Thus if we specify a relative path for the LOG_FILE variable, build.sh will create a number of logfiles in a number of directories.

This is most certainly not the expected behaviour.

The <sdk>/examples/android/ExampleApp/README.md file only says the following:

If you want a more verbose output to inspect the output looking for build errors, change the LOG_FILE variable in the build.sh script from /dev/null to /dev/stdout or to a file like /tmp/build.log

This doesn't imply (yet) that using an absolute path is mandatory (or else ...).

To Reproduce

Steps to reproduce the behavior:

  1. Checkout sdk repo.
  2. Change current working directory to <sdk>/examples/android/ExampleApp/app/src/main/jni.
  3. Run LOG_FILE=log.txt build.sh all

Expected behavior

Only one logfile is created.

Ideally if the value given to LOG_FILE doesn't start with a /, the current working directory should be prepended.

Currently LOG_FILE is initialized like this:

if [ -z "${LOG_FILE}" ]; then
    # If no build log variable is defined, use below value.
    LOG_FILE=/dev/null # Ensure you use a full path
fi

Instead it should be something like this:

if [ -z "${LOG_FILE}" ]; then
    # If no build log variable is defined, use below value.
    LOG_FILE=/dev/null # Ensure you use a full path
elsif [ "${LOG_FILE:0:1}" != "/" ]; then
    LOG_FILE="$(pwd)/$LOG_FILE"
fi

If this is not a desired solution, the README.md should explicitly say that an absolute path should be used, or there'll be a number of logfiles created throughout the tree of the <sdk>/examples/android/ExampleApp/app/src/main/jni directory.

Screenshots

I don't think this is necessary, since the bug/issue (and a potential fix) is well described. And it's trivially reproducible.

Environment:

  • SDK Version: v9.16.1
  • OS: Ubuntu 22.04.5 LTS
  • Device: Android

Additional context

No additional context.

Metadata

Metadata

Assignees

Labels

bugUnexpected software behaviour

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions