Tuesday, October 29, 2019

More Library Updates

Cachify and Highlander have received small bugfix updates today. Cachify has bumped to 0.0.4 and Highlander to 0.0.3.

Cachify has changed to allow for more verbose logging when enabled regarding what steps the runner is taking at what point in time. The multi-backend setup is also now backed by a Mutex to guard against concurrent access of an Orchestrator over different coroutines. It also fixes a bug where - if a cache is spam called quickly enough, the runner will attach and await a coroutine which is already completed or cancelled - which would cause the Orchestrator to attach to a runner that returned a value successfully - but tossed it out into the void.

Now the runner will check that an active task is still currently alive, and only attach to it if that is the case. If a task is active - but cancelled or completed, the runner will consider the task no longer active and clear it out - and then it will wait for a new active task, or take over as the active task.

With these library updates, PYDroid 20.6.1 has been released which just pulls in these new library versions.

These small bugs were discovered as part of a testing run on FridgeFriend to make sure that it can correctly handle users spamming buttons, clicking around, and any such other nonsense. Every day I am getting closer and closer to preparing for a release - and then I get to battle the new Play store and its policies -_-

Thanks for your patience, this has been a passion project of mine for the past year or so now and I'm really excited to see it nearing completion!

Stay tuned!

========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?

Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com

Follow my Facebook Page
Check out my code on GitHub
=========================

Wednesday, October 23, 2019

Android Studio on Android

Kind of. Sort of. It's not perfect. Temper your expectations - and continue.

Let's set the stage - I have a Samsung Galaxy S10. Its a powerful device - 8GB of ram, 8 cores around 2GHz or so, not too bad for a pocket computer. It should be able to do things that a pocket computer would be expected to do - like run computer applications in my pocket. I like to code, I like to travel - I like to code while I travel and I didn't enjoy carrying around a seperate laptop everywhere. Here is my journey at trying to get Android Studio to run on Android.

What you'll need:

Patience.
UserLand
bVNC
Patience
A phone running Android
Basic Linux knowledge
Patience


What you'll be asked to download

Android Studio
The Android SDK
The Java JDK 8 built for ARM devices
Optionally the Kotlin compiler built for ARM devices


The rest of this assumes that you have some basic Linux knowledge and are insane enough to attempt running Android Studio off your Android phone.

First you should download, install, and setup Userland. I picked from a simple Ubuntu option and chose to connect over SSH. Once the Ubuntu install is finished, I launched into an session from the Userland app, and installed the following components from the package manager apt:

openjdk-8-jdk build-essential ubuntu-make tigervnc-standalone-server tigervnc-xorg-extension adb aapt

You will also need at least one android-platform from the package manager - on Ubuntu its platform 23. It's out of date, but that doesn't matter - we just need it so that Android Studio believes we have a valid SDK install. You'll also need to install Android Studio from the website - NOT the package manager. Head over to the Android Studio website and download Android Studio and the Android SDK for Linux tar files. You need to download the SDK seperately since the one bundled with Android Studio does not work on ARM.
From this point forward, I will refer to the SDK files as the Android SDK, and the stuff you got from the package manager as the repo SDK.

To steel your nerves for what you are about to get yourself into - largely things don't really work. You can expect many issues - know that if anything doesn't work your first instinct should be to try and replace whatever the file in the Android SDK is with the repo SDK.



You'll first need to set up TigerVNC so that you can connect to a graphical desktop session - you'll need to know a little bit about setting up VNC here, but here are the scripts I use every day to connect to the VNC server that I have set up on my phone.

The reason we want TigerVNC over the Userland default TightVNC is that Tiger supports the XRANDR extension - which we need to launch Android Studio. Use the absolute latest TigerVNC release for the best performance.

You can also install the DE or WM of your choice (I opted for XFCE4).

Once everything is downloaded, launch Android Studio and point it to the SDK you just downloaded. You can attempt the first time setup wizard - but it will most likely fail. That's expected - it is usually expecting to run things like adb or mksdcard which don't run on arm. Click on through as far as you can get and mark the wizard to not re-run. Close Android Studio.

Now for the first sync/index/file download. The first thing you'll need to do is STOP using the embedded Android Studio JDK - you'll have to go into both your Project Properties as well as the Default Project Properties and change the JDK target to the ARM JDK 8 you installed from the package manager, usually in /usr/lib/jvm. If you do not do this for both Project and Default settings, Gradle will not run. You will also want to manually copy the aapt, aapt2, and adb binaries you installed from the repo and replace the ones in your Android SDK location. For me, this meant copying /usr/bin/adb over ~/Android/sdk/platform-tools/adb and such. You'll also want to copy the repo-SDK Android platform that you installed (in my case platform-23) over to the correct directory in the Android SDK.

Once you have done this, open Android Studio and open the Settings popup - head over to the Android SDK settings under General - it should warn you about not finding any Android SDK setup because it failed earlier in the setup wizard. Click the SDK path to open the path picker and select your Android SDK location - this time it should treat the path as valid because you have a working adb, aapt, and 1 valid Android platform. It should succeed and now you can manage the Android SDK from Android Studio.

Download all the updates and get the latest platforms you need to support and all that fun stuff. One note - when installing a new Android platform there is a step during the process where Android Studio will attempt to stop the running ADB daemon. This step will fail if you have not put the repo-SDK adb file over the Android SDK one. NOTE that you must install the Build-Tools, SDK-Tools, and Platform-Tools file first on their own - copy over the old adb binary - and then install any new Android platform SDK updates. If you do not do things in this order the update will not go through.

Once you have done this, you should be able to attempt your first build - as long as what you are building is a library project. Normal Android applications will not build successfully because of the resource merge step which requires them to run aapt2 - aapt2 is not built for ARM in the Android SDK and so it will fail to run. Library projects should compile fine because they do not run aapt2, but normal Android applications do. Sadly this is a limitation of ARM at the moment - the only way to compile your normal Android applications is to change the plugin from 'com.android.application' to 'com.android.library', and in doing so you will be able to compile, but not actually build an APK on to your device. It's better than nothing I guess. You can see an example of what I mean here.

If you use kotlin (you should), you'll also need to manually build your own kotlinc so that it will run on ARM instead of using the version shipped with the Kotlin plugin. You can do this using ubuntu-make.

If you want to run platform tools like fastboot, you can install their packages from the package manager repository - but you won't be able to mix and match them with your current Android SDK. Even if you manage to install an ARM version of aapt2, when you go through a build in Android Studio it attempts to access a version of aapt2 from the ~/.gradle/caches directory which will not work - so its a dead end for now.

At the long end of your tiring journey - you have a phone which can adb to itself over VNC, a sort-of Linux distribution running on the same hardware that runs your Youtube app, and a way to - if nothing else - at least code and compile Android apps on the go. It works great in Samsung Dex mode, and can actually provide some decent results. It's not perfect, but its a fun little excercise in trying to get Linux onto everything that has a chip - and hopefully it will only get better in the future.

Stay tuned.

========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?

Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com

Follow my Facebook Page
Check out my code on GitHub
=========================

Friday, October 18, 2019

Library updates

PYDroid 20.5.0 is released, bringing the new hook style initializer and teardown handlers I mentioned in the last post! As mentioned before, the old function inheritance style is still present - and will continue to work until 21.0.0 at which point it will be unceremoniously slaughtered for the greater good.

Along with PYDroid, Cachify has seen a new release bringing it to version 0.0.3! The new release is backwards compatible with 0.0.2 syntax wise (but not binary compatible - sorry) and lays the groundwork for a full repository pattern. Cachify 0.0.3 now allows you to specify a list of CacheStorage objects, which will be iterated through one after the other when looking for cached data. The first object to present valid cached data will be returned, and only if no CacheStorage objects contain valid data will the upstream be hit. This change is transparent for consumers, and the simple syntax for creating a Cached instance which is backed by a memory cache storage is unchanged.

The one change though - previous releases of Cachify used public inline functions and called through to internal library implementations via the @PublishedApi annotation. With 0.0.3, this annotation has been removed, making the library not binary-compatible with 0.0.2. Unless you have a very strange setup, you should not notice this change at all.

And with the release of Cachify 0.0.3 also comes PYDroid 20.6.0! Wait what? Two releases of PYDroid in the same evening? Why yes! For those of you who do not know, PYDroid is this mishmash library which contains other libraries - like Coroutines, Cachify, and Highlander. The only difference between 20.5.0 and 20.6.0 is that 20.6.0 brings support for the new Cachify 0.0.3! I didn't want to remove the already released version and I figure its nice to know that not too many things are changing at once. For those who want to play it safe, you can use 20.5.0, but if you are adventurous and daring, try the new 20.6.0!

I'm hard at work on actual applications too - FridgeFriend is nearing completion and once it is done it will go out with the other pyamsoft applications - bringing support for Android 10 and all its shiny new things!

Stay tuned!

========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?

Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com

Follow my Facebook Page
Check out my code on GitHub
=========================