Author Topic: Hello Android! How to build Android Apps using QB64  (Read 40319 times)

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 5486
  • QB Forever
Hello Android! How to build Android Apps using QB64
« on: October 31, 2015, 01:14:22 pm »
Follow the directions below. The attached zip file contains the below instructions as well as screenshots of the setup process.
If you get stuck or get any errors, reply to this post or start a new topic in this forum area.

Code: [Select]
HOW TO SETUP QB64 FOR BUILDING ANDROID APPS
===========================================

IMPORTANT (you really should read this)
=========
* Follow the numbered steps below in the correct order or you will have problems
* QB64 currently builds projects which target ARM-based processors not x86 processors. No testing on x86 has been done (it should work in theory if you change the target).
* QB64 Android projects have only been extensively tested on a Samsung Galaxy S5 (but should run on other Android devices too)
* If you already have the Android NDK installed from the days when QB64 used Eclipse+NDK remove it to avoid potential conflicts (or set an explict path to the new NDK in located_files.txt [see notes below])
* Android Studio and its tools are constantly being updated. As such, the version of Android Studio you install won't come preconfigured with the components to build your project's version.
  In most cases, you simply need to open the Android SDK manager (as we do in Step 4 below) to install required components if your project fails to build in Android Studio

NOTES (read this if you get stuck or are curious)
=====
* QB64 will search C: for specific files, you can help it find the files faster by adding the full path to the list of files in:
C:\ANDROID_2015\qb64v0000-win\qb64\programs\android\template\located_files.txt
If some of the paths listed in this file are incorrect don't worry, QB64 will only use files it has physically verified the existance of.
  These files currently are:
AVD Manager.exe
ndk-build (no extension)
gradle.bat
  If you installed components on a different drive you will have to manually add paths to this file.
  Be aware that if QB64 cannot find the files, it will put default locations into your project which won't match your system.
* When your programs run, "File not found" errors will probably be the most common:
  i) Use the $INSTALLFILES and $INSTALLFOLDER commands in your .BAS file to tell QB64 which assets to include
     The typical pattern I use for specific files in a folder is:
     $INSTALLFILES "folder_relative_to_bas_file\*.jpg" IN "bas_file_folder_relative_to_qb64_exe\folder_relative_to_bas_file"
     The typical pattern I use for a folder containing all assets (including all files in sub-folders and maintaining directory structure) is:
     $INSTALLFOLDER "folder_relative_to_bas_file" IN "bas_file_folder_relative_to_qb64_exe\folder_relative_to_bas_file"
     You can specify multiple $INSTALLFILES/FOLDERS metacommands if you need to.
  ii) Remember that Android is Linux based, so all your filenames are case sensitive.
     (I usually make everything lowercase, in fact you can get tools to convert entire directory trees to lowercase)

INSTALLATION STEPS
==================

1) Download the latest Windows dirty build version of QB64 (timestamp [2015_10_30__06_19_29] or newer)
Do not try to build an Android project yet. QB64 will search for C: for specific files in the NDK and Android Studio and it can be a long wait if it cannot find them.

2) Android Studio requires the Java Development Kit (JDK) 6 or higher (NOT the JRE, JRE will be installed automatically by the JDK), so download & install this first
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
For example, if you are using 64-bit Windows you would download "Windows x64 - jdk-7u79-windows-x64.exe" [~140MB]

3) Download and install Android Studio (includes SDK) with the default options from the following link [~1.1GB]
http://developer.android.com/sdk/index.html
(This is a 1.1GB download)

4) Open Android Studio and select configure [1.png] and then SDK manager [2.png].
   In the SDK Platforms tab, install API level 21 (Android 5.0.1) [3.png]
   In the SDK Tools tab, install Android NDK [4.png]
   Now exit Android studio (Sometimes Android Studio needs to be restarted to detect changes)

5) Locate the file "C:\Users\{YourUserName}\AppData\Local\Android\sdk\ndk-bundle\build\core\default-build-commands.mk"
   Modify the TARGET_CXXFLAGS line to also contain "-fpermissive"
   For example:
   TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti -fpermissive

6) Open QB64 and enable the Android Run Menu commands [5.png & 6.png]

7) Create the test program provided, save it as HelloAndroid.bas, then select Make Android Project from the Run menu [7.png]
'-------------------------------------------
DO
    COLOR RND * 15
    PRINT "Hello Android!";
    _DISPLAY
    _LIMIT 30
LOOP
'-------------------------------------------

8) Open the project in Android Studio [8.png]
   Your project will begin to build immediately, open the Gradle Console tab (bottom right) [9.png] and wait for it to complete
   (It is normal to get warnings here, but you should not get any errors)

9) Press the 'green play triangle icon' in the row of icons at the top of Android Studio
   Wait for Android Studio to display a list of available devices (make sure your Android device is in USB-debugging mode and select trust this computer if prompted)
   Select your device and run your APP [10.png]

You can also find these instructions on our Wiki:
http://www.qb64.net/wiki/index.php/Android_Project
« Last Edit: March 20, 2016, 05:51:53 am by Galleon »
Something old... Something new... Something borrowed... Something blue...

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #1 on: November 01, 2015, 11:41:06 am »
I'm assuming that the QB64 Android IDE look for the stuff in default installation folders?

I copied your instructions to the WIKI here. Please feel FREE to edit as always:
http://www.qb64.net/wiki/index.php/Android_Project

I found it a bit difficult scrolling...  ;)

How do we set this?

Quote
make sure your Android device is in USB-debugging mode and select trust this computer if prompted

Sure wish we could put the pictures there too! Now that you run the server maybe you can add that ability for some things. The old setup is still saved if we ever need it. Do we?
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 5486
  • QB Forever
Re: Hello Android! How to build Android Apps using QB64
« Reply #2 on: November 02, 2015, 12:24:58 am »
Quote
How do we set this?
This depends on the exact version of Android as well as if the manufacturer has customised that version.
For Samsung Galaxy S5 it is ridiculous. You have to click your heels together 7 times...
https://www.youtube.com/watch?v=7QkxBYL-HKc
Something old... Something new... Something borrowed... Something blue...

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #3 on: November 02, 2015, 06:07:03 am »
Tried that on my Nexus 7 and went to Settings, About device

Pressed Build Number 7 times to become a developer. Prompt kept a count down.

Then a prompt said "You are now a developer".

Now USB Debugging is listed in a Developer menu next to About in Settings.

No sweat!
« Last Edit: November 03, 2015, 05:39:14 am by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Pete

  • Hero Member
  • *****
  • Posts: 7368
  • Cuz I sez so varmint!
Re: Hello Android! How to build Android Apps using QB64
« Reply #4 on: November 02, 2015, 12:19:34 pm »
Did you have the sound off Clippy, 'cause I'm pretty sure it was laughing when it printed, "You are now a developer."

I had to go through that process when I started programming in AndroidBasic.  Thankfully there were references to how to set it up online, but the Wizard one here is pretty funny.

Pete
Give a man a program, and he does one thing for a day. Teach a man to program, and he does one thing for a lifetime.

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #5 on: November 03, 2015, 04:02:27 pm »
Galleon is command line compilations fixed? Saw update here:

https://github.com/galleondragon/qb64

Noted that page refers to: Automatically exported from code.google.com/p/qb64
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

wiggins

  • Sr. Member
  • ****
  • Posts: 447
Re: Hello Android! How to build Android Apps using QB64
« Reply #6 on: November 03, 2015, 04:49:11 pm »
You were not kidding...you click on the menu item 7 times to get into developer mode....

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #7 on: November 03, 2015, 05:00:13 pm »
Just like Dorothy eh? I guess they don't want everybody to hit the Build Number accidentally.

My Nexus counted down after 3 times saying "4 more presses to become a developer"...
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

jc3bull

  • Full Member
  • ***
  • Posts: 110
Re: Hello Android! How to build Android Apps using QB64
« Reply #8 on: November 04, 2015, 08:47:26 pm »
If my games assets are located at ...

c:\qb64\pland\

What do I set $INSTALLFOLDER to so it will include that folder and all of it's subfolders?

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #9 on: November 05, 2015, 07:59:18 am »
From what I can see in 8.PNG, Galleon installed QB64 in C:\Android_2015\qb64v0000-win\qb64
but we can install anywhere we need to right?

The latest dirty QB64 build will put Android code projects into  qb64\programs\android

So I assume JDK and Android Studio are somewhere else right?

Default paths that QB64 will look for?

BTW, This release will be the last Oracle JDK 7 publicly available update. What then?

 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
« Last Edit: November 05, 2015, 08:19:44 am by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #10 on: November 05, 2015, 09:58:39 am »
Stuck in Gradle, whatever that is! It finally tried to run, brought up a phone image with nothing on it, but nothing on my Nexus 7



Cannot find my device, tried virtual and nothing there either. Tablet uses Android 4.4.3

Located_Files
Quote
c:\ndk\ndk-build
c:\Program Files\Android\Android Studio\gradle\gradle-2.2.1\bin\gradle.bat
c:\Users\Robert\AppData\Local\Android\sdk1\AVD Manager.exe
c:\Program Files\Android\Android Studio\gradle\gradle-2.4\bin\gradle.bat
c:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\adt-bundle-windows-x86-20131030\sdk\tools\lib\AVD Manager.exe
c:\Users\Public\Documents\Embarcadero\Studio\15.0\PlatformSDKs\android-ndk-r9c\ndk-build

Path for NDK is C:\NDK\ndk-build but I cannot find it on my drive! It did install, but seemed to be near SDK. Took 15 minutes to unzip...

Robert is definitely wrong. Embarcadero?
« Last Edit: November 05, 2015, 10:25:31 am by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 5486
  • QB Forever
Re: Hello Android! How to build Android Apps using QB64
« Reply #11 on: November 06, 2015, 03:07:04 pm »
Don't worry too much about the invalid paths. As long as at least one of them points to the correct file [ndk-build, gradle.bat, AVD Manager.exe] you should be fine. And as far as I can see they do.

1) Looks like you got two errors in the even log (click on tab in bottom right). Can you give me a screenshot of the errors?
2) That emulator is an x86 device emulator and as I said it probably won't work yet. Maybe create a new virtual machine with an ARM-processor?
Something old... Something new... Something borrowed... Something blue...

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #12 on: November 06, 2015, 06:35:08 pm »
Well Android Studio is not finding my Nexus. I tried adding a closer Android version to 4.4.3, but no luck there either.

QB64 paths were edited to work with paths I have, but if Android cannot find my device everything else is useless. I assumed I could install QB64v0000 anywhere right? I did not use c:\Android2015\ etc...like you had.
« Last Edit: November 06, 2015, 06:45:55 pm by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

jc3bull

  • Full Member
  • ***
  • Posts: 110
Re: Hello Android! How to build Android Apps using QB64
« Reply #13 on: November 06, 2015, 08:50:16 pm »
Well Android Studio is not finding my Nexus. I tried adding a closer Android version to 4.4.3, but no luck there either.

Android Studio not detecting your device is not related to the path QB64 is in. It's a totally separate issue. To get your device to work you need to enabled developer mode (on the device) and then install the drivers for the device (under Windows).

Clippy

  • Hero Member
  • *****
  • Posts: 19399
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Hello Android! How to build Android Apps using QB64
« Reply #14 on: November 07, 2015, 05:59:20 am »
No kidding! I can't talk about BOTH THINGS in the same post? I highlighted for morons too!

Windows 10 recognizes it and I can get to the drive, what other drivers are you talking about?

BE SPECIFIC or say nothing at all!
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL