Android Programming for Beginners

Hello folks!

I haven’t programmed for Android in several years and only dabbled when I did.

In the past, I’ve used:

I actively engage with the broader programming community (outside this forum) and provide general instruction, including Processing. I’d like to expand that instruction to include Android development as well, starting with Processing-based tools.

Every time I return to Android programming, it feels like starting from scratch. New versions, setup issues, and tooling changes can be a bit of a hurdle.

Any general guidance to help get up and running quickly would be appreciated. Our communities benefit from shared experience, especially when it comes to keeping things accessible for beginners.

I’m an autodidact and will figure it all out in due time… but I don’t have that time right now.

I’m sharing this topic on behalf of some passionate learners who are following along but do not have permission to post themselves.

Please direct responses to the community visiting here rather than just me.

Kindly tailor your responses to be beginner-friendly for those new to Android programming using Processing.

I will also respond to this as my exploration unfolds.

:blush: This thread can serve as a useful resource for everyone and especially beginners.

:japanese_symbol_for_beginner: KISS Keep it Super Simple

*** UPDATE ***

Please clearly state your development environment when providing feedback.
This is good advise for any topic.
Each OS (Operating System) may have its unique issues.
With each new update things change and this helps navigate the waters.

For example:

Development environment:

  • Windows 10
  • Processing 4.4.4
  • Motorola Android Phone (Android version 14)
  • Android Mode for Processing 4.6.1 (Installed July 28).
  • I did an SDK update

Thanks!

:)

Is this simple enough:

void setup() {
  fullScreen();
  background(209);
  fill(0, 255, 0);
  rect(200,200,400,400);
}

void draw() {  
}

But don’t try to run this on the latest Processing version 4.4.4 because it no longer works in Android mode and is a known issue. Instead use version 4.3 to get it to work. In my opinion the user needs to use Android Studio and Processing in tandem. Android Studio mainly just helps in getting the right files in the right places. It’s more complicated than it needs to be but we’ve been told that it’s being worked on and I’m sure that it’s not easy from a developer standpoint. That said Processing with Android mode is still far easier to use than the alternative in my opinion and I would like to see a lot more future development in this area by our programmers. One of the problems is what to use for ‘widgets’. It’s fun to create your own but the good ones are created using official Android Developer code which is of course more complicated. There have been several published examples, eg GitHub - vsquared/AndroidWidgets_Processing4: Android controls for use in Processing 4.1.1 Android mode. Device is 10" Samsung tablet in landscape orientation.

Thanks for the feedback.

I found your issue on GitHub here:
Android mode no longer works in Processing 4.4.1 · Issue #777 · processing/processing-android · GitHub

The GitHub issue is for a MacOS and does not mention Windows.

I did a Windows test with this configuration:

  • Windows 10 Pro Version 22H2
  • Processing 4.4.4
  • Motorola Android Phone (Android version 14)
  • Android Mode for Processing 4.6.1 (Installed July 28).
  • I did an SDK update from the Processing menu.

It seemed to work out of the box:

I was not able to get the emulator working in Android Mode for Processing 4
Not yet!

Code
void setup() {
  // Use full screen mode
  fullScreen(P3D);
  noStroke();  // Optional: Remove stroke for 3D objects
}

void draw() {
  background(0);  // Set background to black
  
  lights();
  
  // Move the origin of the coordinate system to the center
  translate(width / 2, height / 2, 0); 
  
  // Rotate the box over time
  rotateX(frameCount * TAU/360); 
  rotateY(frameCount * TAU/360); 

  // Draw a 3D box
  fill(255, 0, 0);  // Red color for the box
  box(200);  // Draw a 3D box with size 200 units
}
Console output
Build folder: D:\temp\android643224006342175877sketch
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.1.0) was tested up to compileSdk = 32

This warning can be suppressed by adding
    android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:mergeDebugNativeDebugMetadata NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:checkDebugAarMetadata
> Task :app:createDebugCompatibleScreenManifests
> Task :app:extractDeepLinksDebug
> Task :app:processDebugMainManifest
> Task :app:processDebugManifest
> Task :app:mergeDebugShaders
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets
> Task :app:compressDebugAssets
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:checkDebugDuplicateClasses
> Task :app:mergeDebugJniLibFolders
> Task :app:mergeDebugNativeLibs NO-SOURCE
> Task :app:stripDebugDebugSymbols NO-SOURCE
> Task :app:validateSigningDebug
> Task :app:writeDebugAppMetadata
> Task :app:writeDebugSigningConfigVersions
> Task :app:processDebugManifestForPackage
> Task :app:mergeDebugResources
> Task :app:processDebugResources
> Task :app:desugarDebugFileDependencies

> Task :app:compileDebugJavaWithJavac
Annotation processing got disabled, since it requires a 1.6 compliant JVM

> Task :app:dexBuilderDebug
> Task :app:mergeDebugJavaResource
> Task :app:mergeExtDexDebug
> Task :app:mergeDexDebug
> Task :app:packageDebug
> Task :app:createDebugApkListingFileRedirect
> Task :app:assembleDebug

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 8s
27 actionable tasks: 27 executed
Exploration < Click to expand!

Related posts:

Additional references:

:)

For what it’s worth …

I too started Android development using Processing, about 12 years ago. My specific area of interest was (still is) audio/music but I needed a relatively easy means of creating a GUI and at this, Processing excels! It was my basic introduction to Java coding and it was easy to get quick results!

Beyond the GUI though I had to delve into contributed libraries (Ketai, Minim etc) but as Processing developed, I found that Ketai/Minim were never maintained to support upgrades etc and similarly with a few other contributed libraries, so eventually I took the plunge and exported my Processing sketches and set them up in Android Studio. The basic lesson learnt was that you SHOULDN’T use contributed libraries. As good as they may be, unless they are maintained in line with Processing developments, they will likely at some point stop working.

Moving to Android Studio was a real game changer. Once I’d figured out that I still had setup() and draw() I could just carry on using them as before. No need to bother with XML layouts etc as you have the full screen still as your canvas and can do what you like with it. The big advantage though was discovering I could make use of the much fuller capabilities of the Android SDK for audio … MediaPlayer, AudioTrack etc. And once you know how to read into the SDK you can find all sort of other useful stuff. I then found that all this can also be done in Processing too so perhaps not quite the game changer I initially thought it might be! The point though is that it expanded my horizons and now I can do both. I still use Processing for sketching ideas but then shift to Android Studio to finish.

The biggest issue though re Processing vs Android Studio is the lag in development of Processing Android Mode to keep pace with the ever/regular/often rule changes that Google introduces … SD Card access permissions… minimum and target SDK requirements if you want to put anything on Google Play. It’s a bit more effort to keep track of SDK target and version numbers but not difficult once you know which files to edit.

If you do export to Android Studio, you will also discover that Processing has hidden from you the onCreate(), onStart(), onResume(), onPause(), onStop() and onDestroy() methods that define an android app lifecycle … and if you are teaching android development then you should know about them.

What else do you want to do beyond displaying cool graphics?
Do you want to be able to play audio?
Do you want to be able to access file storage?
Do you want to learn about the android app lifecycle?

Do your learners just want to code and deploy to just their own device or do they want to publish on Google Play and learn more about Android? If the latter get set up in Android Studio. If the former then use Processing but accept its limitations.

2 Likes

Hello @shedMusic ,

Thank you for the feedback.

My development journey was similar to yours but very limited in scope and time spent on this.
I would test the waters and get some simple projects up and running.

It is early days yet and will start with Android Mode for Processing and focus on that before taking any next steps.

My current Windows 10 development environment:

  • Windows 10 Pro Version 22H2
  • Processing 4.4.4
  • Motorola Android Phone (Android version 14)
  • Android Mode for Processing 4.6.1 (Installed July 28).
  • I did an SDK update from the Processing menu.

I got a simple example working (see previous posts).

Are you aware of any known issues for this?
Can you test and confirm?

I was not able to get the emulator working in Android Mode for Processing 4.
I did get it to launch manually to see if it was working… but not in Android Mode with a Processing sketch.

Other operating systems (MacOS, Linux, etc.) would be a separate discussion.

:)

I use a MacBook but have access to a PC … I’ll set it up and get back to you :+1:

1 Like

Yet!

Topic here:

:slight_smile:

Hi

Just been tying to download to a borrowed windows 10 laptop but can’t even do that …. bombs out at around 265MB .. tried 3 times. I do have a pc with all this installed but it’s in storage while I move house…

I’ll post some thoughts re android though based on my MacBook coding which should be the same in terms of how it all works, but I think I’ll leave the PC until later in August.

I just tried the test sketch from my initial post on a Windows 11 system using Processing 4.4.4 (Android Mode latest 4.6.1) and it failed with the following error (same as what I saw on Mac M2 with Samsung A8 device). Sorry that I had to post an image of the console output, but Processing won’t allow me to copy console output.