XusinboyBekchanov / VisualFBEditor

IDE for FreeBasic
Other
176 stars 39 forks source link

Error: Android Building Issues - Hard-coded Paths in IDE #438

Closed simulanics closed 1 year ago

simulanics commented 1 year ago

After setting up the IDE to run an Android application, upon trying to run/compile, I'm seeing the following error

Error: File not found, "jni.bi"

Screenshot 2022-12-12 111530

This is current release available

XusinboyBekchanov commented 1 year ago

What is the compilation line?

XusinboyBekchanov commented 1 year ago

You must open File -> Open Folder -> "Examples" folder -> "AndroidProject" folder.

Then compile.

simulanics commented 1 year ago

You must open File -> Open Folder -> "Examples" folder -> "AndroidProject" folder.

Then compile.

I am doing this exactly. After opening the example project and pressing run, it saying for line #38, that jni.bi cannot be found. I have searched the forums also and do see Java Native Interface - but there are no working links to any resources for this item. I tried downloading older versions of FB to see if the header would be included - it was not unfortunately. Still looking for the resource online.

XusinboyBekchanov commented 1 year ago

This file is available in this path: fbc-android\include\freebasic\jni.bi

simulanics commented 1 year ago

Thank you! I had the path setup wrong. With all paths now corrected, it seems to attempt to compile, but now is saying that mff has some missing and undeclared items. This is great work!! Thank you for all your help. I'll peek in the mff files and see if I can find where the issues are. Snippet included below of the debug showing lines with errors.

Screenshot 2022-12-12 114532

XusinboyBekchanov commented 1 year ago

Yes, in version 1.3.3 there was such a bug. You need to download 1.3.4 from github, an unreleased version.

XusinboyBekchanov commented 1 year ago

DownloadAndCompileWithQuestions.bat - It downloads and compiles the IDE and mff.

simulanics commented 1 year ago

I apologize for all the questions. This worked perfectly.

I'm trying to make a write-up on how to compile on windows to make it easier for other developers. I've now been able to successfully compile and resulted in the following screenshot. It shows that "libmff-app.so" was built. Then it shows "Application do not run. Error code 193 -". I'm attempting to use Android v 28. I also noted that GCC is no longer included in NDK as of 2018, is there a way to update android compilations using i686-linux-androidXX-clang++?

runcomplete

What is this error? I do have android emulator installed on the system. How do I now build/run the apk? I noted that no new APK was generated in the release or debug directories but libmmf-app.so did build. I think I'm missing a step to run the application.

Thank you again for all your help.

simulanics commented 1 year ago

I was able to build a successful bundle and APK after looking thru the source code and using the gradle.bat commands. It appears there are a few places in the IDE/Android Template code where D:* directories are hardcoded. From what I can see, for example when you press build bundle, the following error appears:

File C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\AndroidProject.vfp/gradle.properties not found!

**Where the project name should be removed from the directory in order to find gradle.properties. Directory assumed to be: C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\AndroidProject.vfp/gradle.properties Is actually: C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\gradle.properties

For the time being - once the libmmf.so has been built, I'm having to use a workaround for the hard-coded 'bad' directories' in the IDE:

1) open a command line 2) cd to the project directory 3) open the grade/build files, update the paths to reflect system paths (these don't match the IDE settings**) & save 4) run "gradew.bat bundle" or "gradew.bat build"

**I also had to set 3 environment paths on windows for the NDK bin directories for GCC & ABI for them to be found. Windows will not recurse into subdirectories so when the NDK main directory is specified, I still also needed to add:

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\x86-4.9\prebuilt\windows-x86_64\bin

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin

XusinboyBekchanov commented 1 year ago

I've now been able to successfully compile and resulted in the following screenshot. It shows that "libmff-app.so" was built. Then it shows "Application do not run. Error code 193 -".

If you open the project itself, it only compiles one library. If you open the folder containing this project (i.e. AndroidProject) via "Open folder" then gradlew.bat is launched and creates three libraries for each architecture (x86, arm64-v8a, armeabi-v7a). You can specify more in the gradlew.bat file. There are six types of architecture in the fbc-android\lib\freebasic folder.

I'm attempting to use Android v 28. I also noted that GCC is no longer included in NDK as of 2018, is there a way to update android compilations using i686-linux-androidXX-clang++?

To do this, we need to change some things in the compiler.

What is this error?

Says it can't run dll.

I do have android emulator installed on the system. How do I now build/run the apk? I noted that no new APK was generated in the release or debug directories but libmmf-app.so did build. I think I'm missing a step to run the application.

I was able to build a successful bundle and APK after looking thru the source code and using the gradle.bat commands. It appears there are a few places in the IDE/Android Template code where D:* directories are hardcoded. From what I can see, for example when you press build bundle, the following error appears:

File C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\AndroidProject.vfp/gradle.properties not found!

**Where the project name should be removed from the directory in order to find gradle.properties. Directory assumed to be: >C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\AndroidProject.vfp/gradle.properties Is actually: C:\Users\Matthew\Desktop\VisualFBEditor\Examples\AndroidProject\gradle.properties

For the time being - once the libmmf.so has been built, I'm having to use a workaround for the hard-coded 'bad' directories' in the IDE:

open a command line cd to the project directory open the grade/build files, update the paths to reflect system paths (these don't match the IDE settings**) & save run "gradew.bat bundle" or "gradew.bat build"

As said above, it was necessary to open as a folder.

**I also had to set 3 environment paths on windows for the NDK bin directories for GCC & ABI for them to be found. Windows will not recurse into subdirectories so when the NDK main directory is specified, I still also needed to add:

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\x86-4.9\prebuilt\windows-x86_64\bin

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin

C:\Users\Matthew\Desktop\VisualFBEditor\Compilers\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin

-sysroot is specified in the command line, it finds these compilers itself, it is not necessary to add to environment variables.

XusinboyBekchanov commented 1 year ago

The logic of compiling and running (also other commands for Android) works like this: image

We can of course change the logic for the better.

hustbeef commented 1 year ago

Yes. we should change the logic and remove mennu items "open as a folder". "open as a folder" and Android Projects are the same type project which can not working with buttom "folder" on tbExplorer. A boolean like ProjectIsFolder could be add to Type ProjectElement.

XusinboyBekchanov commented 1 year ago

I agree with it.

XusinboyBekchanov commented 1 year ago

This fixed on version 1.3.4.