Build Android Via Tools/package_android.sh Fail

by ADMIN 49 views

Introduction

Building Android applications using the tools/package_android.sh script can be a complex process, especially when encountering errors. In this article, we will delve into the issue of building Android applications using the tools/package_android.sh script failing, and provide solutions to resolve the problem.

Error Message and Log

The error message and log are as follows:

...
...
...
Compiler for C supports arguments -Waggregate-return: YES 
Compiler for C supports arguments -Wold-style-definition: YES 
Compiler for C supports arguments -Wdeclaration-after-statement: YES 
Compiler for C supports arguments -Wno-error=varargs: YES (cached)
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency capi-ml-common found: YES 1.8.6
Run-time dependency capi-ml-inference found: YES 1.8.6
Message: preparing blas

meson.build:311:4: ERROR: Include dir openblas/include does not exist.

A full log can be found at /home/m.wlasiuk/Desktop/nntrainer/builddir/meson-logs/meson-log.txt

Full Log Report

The full log report is as follows:

...
...
...
Run-time dependency capi-ml-common found: YES 1.8.6
Pkg-config binary for 1 is cached.
Determining dependency 'capi-ml-inference' with pkg-config executable '/usr/bin/pkg-config'
env[PKG_CONFIG_PATH]: 
Called `/usr/bin/pkg-config --modversion capi-ml-inference` -> 0
1.8.6
env[PKG_CONFIG_PATH]: 
Called `/usr/bin/pkg-config --cflags capi-ml-inference` -> 0
-I/usr/include/nnstreamer
env[PKG_CONFIG_ALLOW_SYSTEM_LIBS]: 1
env[PKG_CONFIG_PATH]: 
Called `/usr/bin/pkg-config --libs capi-ml-inference` -> 0
-L/usr/lib/x86_64-linux-gnu -lcapi-nnstreamer -lnnstreamer -lcapi-ml-inference-single -lcapi-ml-common -lnnstreamer-single
env[PKG_CONFIG_PATH]: 
Called `/usr/bin/pkg-config --libs capi-ml-inference` -> 0
-lcapi-nnstreamer -lnnstreamer -lcapi-ml-inference-single -lcapi-ml-common -lnnstreamer-single
Run-time dependency capi-ml-inference found: YES 1.8.6
Message: preparing blas
Running command: /home/m.wlasiuk/Desktop/nntrainer/jni/prepare_openblas.sh /home/m.wlasiuk/Desktop/nntrainer/builddir
--- stdout ---
PREPARING OPENBLAS at /home/m.wlasiuk/Desktop/nntrainer/builddir
~/Desktop/nntrainer/builddir ~/Desktop/nntrainer
[OPENBLAS] downloading openblas-0.2.20.tar.gz\n
[OPENBLAS] Download failed, please check url\n

--- stderr ---



meson.build:311:4: ERROR: Include dir openblas/include does not exist.

Troubleshooting and Solutions

1. Check the URL

The error message indicates that the URL for downloading the openblas-0.2.20.tar.gz file is not correct. To troubleshoot this issue, we can try to access the URL using a web browser or the wget command.

m.wlasiuk@AMDC3803:~/Desktop/nntrainer$ wget  https://github.com/nnstreamer/nnstreamer-android-resource/raw/master/external/openblas-0.2.20.tar.gz
--2025-03-11 14:04:43--  https://github.com/nnstreamer/nnstreamer-android-resource/raw/master/external/openblas-0.2.20.tar.gz
Resolving github.com (github.com)... 20.26.156.215
Connecting to github.com (github.com)|20.26.156.215|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2025-03-11 14:04:43 ERROR 404: Not Found.

As we can see, the wget command returns a 404 Not Found error, indicating that the URL is not correct.

2. Check the GitHub Repository

To troubleshoot this issue, we can try to access the GitHub repository using a web browser or the git command.

m.wlasiuk@AMDC3803:~/Desktop/nntrainer$ git clone https://github.com/nnstreamer/nnstreamer-android-resource.git
Cloning into 'nnstreamer-android-resource'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (1/1), 1.00 KiB | 0 bytes/s, done.

As we can see, the git clone command successfully clones the repository.

3. Check the prepare_openblas.sh Script

The prepare_openblas.sh script is responsible for downloading the openblas-0.2.20.tar.gz file. To troubleshoot this issue, we can try to run the script manually.

m.wlasiuk@AMDC3803:~/Desktop/nntrainer$ ./jni/prepare_openblas.sh /home/m.wlasiuk/Desktop/nntrainer/builddir
PREPARING OPENBLAS at /home/m.wlasiuk/Desktop/nntrainer/builddir
~/Desktop/nntrainer/builddir ~/Desktop/nntrainer
[OPENBLAS] downloading openblas-0.2.20.tar.gz\n
[OPENBLAS] Download failed, please check url\n

As we can see, the script returns an error message indicating that the download failed.

4. Check the meson.build File

The meson.build file is responsible for building the Android application. To troubleshoot this issue, we can try to run the meson command manually.

m.wlasiuk@AMDC3803:~/Desktop/nntrainer$ meson build
The Meson configure file: build/meson.build
C compiler for the host machine: gcc (gcc 9.3.0 "gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0")
C++ compiler for the host machine: g++ (gcc 9.3.0 "gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0")
C compiler for the host machine: gcc (gcc 9.3.0 "gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0")
C++ compiler for the host machine: g++ (gcc 9.3.0 "gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency capi-ml-common found: YES 1.8.6
Run-time dependency capi-ml-inference found: YES 1.8.6
Message: preparing blas
Running command: /home/m.wlasiuk/Desktop/nntrainer/jni/prepare_openblas.sh /home/m.wlasiuk/Desktop/nntrainer/builddir
--- stdout ---
PREPARING OPENBLAS at /home/m.wlasiuk/Desktop/nntrainer/builddir
~/Desktop/nntrainer/builddir ~/Desktop/nntrainer
[OPENBLAS] downloading openblas-0.2.20.tar.gz\n
[OPENBLAS] Download failed, please check url\n

--- stderr ---



meson.build:311:4: ERROR: Include dir openblas/include does not exist.

As we can see, the meson command returns an error message indicating that the include directory openblas/include does not exist.

5. Check the tools/package_android.sh Script

The tools/package_android.sh script is responsible for building the Android application. To troubleshoot this issue, we can try to run the script manually.

m.wlasiuk@AMDC3803:~/Desktop/nntrainer$ ./tools/package_android.sh
...
...
...
meson.build:311:4: ERROR: Include dir openblas/include does not exist.

As we can see, the script returns an error message indicating that the include directory openblas/include does not exist.

Conclusion

Q: What is the cause of the build failure when using the tools/package_android.sh script?

A: The build failure can be caused by a variety of factors, including incorrect URLs, missing dependencies, and incorrect script configurations.

Q: How do I troubleshoot the issue of the build failure when using the tools/package_android.sh script?

A: To troubleshoot the issue, you can try the following steps:

  1. Check the URL: Verify that the URL for downloading the openblas-0.2.20.tar.gz file is correct.
  2. Check the GitHub Repository: Verify that the GitHub repository is accessible and that the necessary files are present.
  3. Check the prepare_openblas.sh Script: Verify that the script is running correctly and that the necessary files are being downloaded.
  4. Check the meson.build File: Verify that the file is correct and that the necessary dependencies are being met.
  5. Check the tools/package_android.sh Script: Verify that the script is running correctly and that the necessary dependencies are being met.

Q: What is the error message "Include dir openblas/include does not exist." and how do I resolve it?

A: The error message "Include dir openblas/include does not exist." indicates that the include directory openblas/include does not exist. To resolve this issue, you can try the following steps:

  1. Verify that the openblas-0.2.20.tar.gz file is being downloaded correctly.
  2. Verify that the script is running correctly and that the necessary files are being downloaded.
  3. Verify that the include directory openblas/include is being created correctly.

Q: How do I resolve the issue of the build failure when using the tools/package_android.sh script?

A: To resolve the issue, you can try the following steps:

  1. Verify that the URL for downloading the openblas-0.2.20.tar.gz file is correct.
  2. Verify that the GitHub repository is accessible and that the necessary files are present.
  3. Verify that the prepare_openblas.sh script is running correctly and that the necessary files are being downloaded.
  4. Verify that the meson.build file is correct and that the necessary dependencies are being met.
  5. Verify that the tools/package_android.sh script is running correctly and that the necessary dependencies are being met.

Q: What are some common issues that can cause the build failure when using the tools/package_android.sh script?

A: Some common issues that can cause the build failure when using the tools/package_android.sh script include:

  1. Incorrect URLs
  2. Missing dependencies
  3. Incorrect script configurations
  4. Incorrect file paths
  5. Incorrect permissions

Q: How do I prevent the build failure when using the tools/package_android.sh script?

A: To prevent the build failure, you can try the following steps:

  1. Verify that the URL for downloading the openblas-0.2.20.tar.gz file is correct.
  2. Verify that the GitHub repository is accessible and that the necessary files are present.
  3. Verify that the prepare_openblas.sh script is running correctly and that the necessary files are being downloaded.
  4. Verify that the meson.build file is correct and that the necessary dependencies are being met.
  5. Verify that the tools/package_android.sh script is running correctly and that the necessary dependencies are being met.

Q: What are some best practices for troubleshooting the build failure when using the tools/package_android.sh script?

A: Some best practices for troubleshooting the build failure when using the tools/package_android.sh script include:

  1. Verify that the URL for downloading the openblas-0.2.20.tar.gz file is correct.
  2. Verify that the GitHub repository is accessible and that the necessary files are present.
  3. Verify that the prepare_openblas.sh script is running correctly and that the necessary files are being downloaded.
  4. Verify that the meson.build file is correct and that the necessary dependencies are being met.
  5. Verify that the tools/package_android.sh script is running correctly and that the necessary dependencies are being met.

Conclusion

In conclusion, the build failure when using the tools/package_android.sh script can be caused by a variety of factors, including incorrect URLs, missing dependencies, and incorrect script configurations. By following the troubleshooting steps outlined in this article, you can identify and resolve the issue, and prevent the build failure from occurring in the future.