Git Product home page Git Product logo

rawdrawandroid's Introduction

rawdrawandroid

Update: Works with OpenXR on Meta Quest!

Table of Contents

rawdrawandroid

Ever wanted to write C code and run it on Android? Sick of multi-megabyte packages just to do the most basic of things. Well, this is a demo of how to make your own APKs and build, install and automatically run them in about 2 seconds, and with an apk size of about 25kB (with API 26). API 30 (Android R+) is unfortunately at 45kB to support ARM64 + ARM32.

With this framework you get a demo which has:

Youtube Video

DISCLAIMER: I take no warranty or responsibility for this code. Use at your own risk. I've never released an app on the app store, so there may be some fundamental issue with using this toolset to make commercial apps!

For support, we have a Discord, but it is not public at the moment, feel free to reach out to @cnlohr on Discord, with a short message as to why you'd like to join, and he can send you an invite!

Why?

Because sometimes you want to do things that don't fit into the normal way of doing it and all the discussions online revolve around doing it with all the normal processes. And those processes change, making it difficult to keep up and do specific things. By using Makefiles it's easy to see what exact commands are executed and add custom rules and tweak your build. C is a universal language. Rawdraw operates on everything from an ESP8266, to RaspberryPi, Windows Linux and now, even Android. Write code once, use it everywhere.

When you don't fill your build process with hills of beans, you end up being left with the parts that are important, and not the frivilous parts. This makes it easier to develop, deploy, etc, because everything takes much less time.

A little bit of this also has to do to stick it to all those Luddites on the internet who post "that's impossible" or "you're doing it wrong" to Stack Overflow questions... Requesting permissions in the JNI "oh you have to do that in Java" or other dumb stuff like that. I am completely uninterested in your opinions of what is or is not possible. This is computer science. There aren't restrictions. I can do anything I want. It's just bits. You don't own me.

P.S. If you want a bunch of examples of how to do a ton of things in C on Android that you "need" java for, scroll to the bottom of this file: https://github.com/cntools/rawdraw/blob/master/CNFGEGLDriver.c - it shows how to use the JNI to marshall a ton of stuff to/from the Android API without needing to jump back into Java/Kotlin land.

Development Environment

Most of the testing was done on Linux, however @AEFeinstein has done at least cursory testing in Windows. You still need some components of Android studio set up to use this, so it's generally easier to just install Android studio completely, but there are instructions on sort of how to do it piecemeal for Windows.

Linux install Android Studio with NDK.

This set of steps describes how to install Android Studio with NDK support in Linux. It uses the graphical installer and installs a lot more stuff than the instructions below. You may be able to mix-and-match these two sets of instructions. For instance if you are on Linux but don't want to sacrifice 6 GB of disk to the Googs.

NOTE You probably should use the WSL instructions instead of these instructions as it will produc a more lean installation.

  1. Install prerequisites:
sudo apt install openjdk-11-jdk-headless adb
  1. Download Android Studio: https://developer.android.com/studio
  2. Start 'studio.sh' in android-studio/bin
  3. Let it install the SDK.
  4. Go to sdkmanager ("Configure" button in bottom right)
  5. Probably want to use Android 24, so select that from the list.
  6. Select "SDK Tools" -> "NDK (Side-by-side)"
  7. Download this repo
git clone https://github.com/cnlohr/rawdrawandroid --recurse-submodules
cd rawdrawandroid
  1. Turn on developer mode on your phone (will vary depending on android version)
  2. Make your own key
make keystore
  1. Go into developer options on your phone and enable "USB debugging" make sure to select always allow.
  2. Plug your phone into the computer.
  3. Run your program.
make push run

Steps for GUI-less install (Windows, WSL)

If you're developing in Windows Subsystem for Linux (WSL), follow the "Steps for GUI-less install" to install the Android components from the command line, without any GUI components.

Extra note for actually deploying to device in Windows

In order to push the APK to your phone, you need adb installed in Windows as well. You can do that by getting the full Android Studio from https://developer.android.com/studio#downloads or directly https://dl.google.com/android/repository/platform-tools_r24.0.4-windows.zip. Installing the full Android Studio is easier, but you can also get the "Command line tools only" and install adb from there. The steps below outline how to do this with the direct link.

Rest of steps

  1. Install Windows Subsystem for Linux (WSL). You can find instructions here: https://docs.microsoft.com/en-us/windows/wsl/install-win10 - we use "Ubuntu" for this.

  2. Install prerequisites:

sudo apt install openjdk-17-jdk-headless adb unzip zip
  1. Download "Command line tools only": https://developer.android.com/studio#downloads - you can get a URL and use wget in WSL to download the tools by clicking on the "Linux" toolset, then right-clicking on the accept link and saying copy link to location. Then you can say wget <link> in WSL.
  2. Create a folder for the Android SDK and export it. You may want to add that export to your ~/.bashrc:
mkdir ~/android-sdk
export ANDROID_HOME=~/android-sdk
printf "\nexport ANDROID_HOME=~/android-sdk\n" >> ~/.bashrc
  1. Unzip the "Command line tools only" file so that tools is in your brand new android-sdk folder.
  2. Install the SDK and NDK components:

For earler versions of tools see note for pre-SDK-32-Tools.

If your platform command-line tools are 30, the command-line tools will be placed in the cmdline-tools folder. So, you will need to execute the following:

yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
$ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;30.0.2" "cmake;3.10.2.4988404" "ndk;21.3.6528147" "platform-tools" "platforms;android-30" "tools"

If you want to target Android 34 (not recommended in 2024, for device compatibility, you will need to execute the following):

yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
$ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;34.0.0" "ndk;26.2.11394342" "platform-tools" "platforms;android-34" "tools" "cmake;3.10.2.4988404"

NOTE If you are upgrading NDK versions, you may need to remove old versions, this Makefile does not necessarily do the best job at auto-selecting NDK versions.

You can see all avialable versions of software with this command:

$ANDROID_HOME/cmdline-tools/bin/sdkmanager --list --sdk_root=${ANDROID_HOME}
  1. Install the Windows ADB toolset.
mkdir -p $ANDROID_HOME/windows
cd $ANDROID_HOME/windows
wget https://dl.google.com/android/repository/platform-tools_r24.0.4-windows.zip
unzip platform-tools_r24.0.4-windows.zip
export ADB=$ANDROID_HOME/windows/platform-tools/adb.exe
printf "\nexport ADB=$ANDROID_HOME/windows/platform-tools/adb.exe\n" >> ~/.bashrc

Alternatively, you may want to use https://dl.google.com/android/repository/platform-tools_r30.0.5-windows.zip for r30.

  1. NOTE: because of updates to environment variables, you may want to close and re-open your WSL terminal.
  2. Download this repo
git clone https://github.com/cnlohr/rawdrawandroid --recurse-submodules
cd rawdrawandroid
  1. Turn on developer mode on your phone (will vary depending on android version)
  2. Go into developer options on your phone and enable "USB debugging" make sure to select always allow.
  3. Plug your phone into the computer.
  4. Make your keystore.
make keystore
  1. Compile and run your program.
make run

If you are going to use this

  • Check out the example here: https://github.com/cnlohr/rawdrawandroidexample

  • You may want to copy-and-paste this project, but, you could probably use it as a submodule. You may also want to copy-and-paste the submodule.

  • You MUST override the app name.

    • See in Makefile APPNAME and PACKAGENAME you should be able to include this project's makefile and override that.
    • You must also update AndroidManifest.xml with whatever name and org you plan to use.
    • You will need to update: package in <manifest> to be your PACKAGENAME variable in Makefile.
    • Both android:label labels need to reflect your new app name. They are in your <application> and <activity> sections.
    • Update the android:value field in android.app.lib_name
  • If you are using permission you have to prompt for, you must both add it to your AndroidManifest.xml as well as check if you have it, and if not, prompt the user. See helper functions below. You can see an example of this with sound_android.c from ColorChord. https://github.com/cnlohr/colorchord/blob/master/colorchord2/sound_android.c

  • Be sure to uninstall any previously installed apps which would look like this app, if you have a different build by the same name signed with another key, bad things will happen.

  • You can see your log with:

adb logcat
  • If your app opens and closes instantly, try seeing if there are any missing symbols:
adb logcat | grep UnsatisfiedLinkError

Helper functions

Because we are doing this entirelly in the NDK, with the JNI, we won't have the luxury of writing any Java/Kotlin code and calling it. That means all of the examples online have to be heavily marshalled. In rawdraw's EGL driver, we have many examples of how to do that. That said, you can use the following functions which get you most of the way there.

struct android_app * gapp;

int AndroidHasPermissions(const char* perm_name);

void AndroidRequestAppPermissions(const char * perm);

void AndroidDisplayKeyboard(int pShow);

int AndroidGetUnicodeChar( int keyCode, int metaState );

int android_width, android_height;

extern int android_sdk_version; //Derived at start from property ro.build.version.sdk

Departures from regular rawdraw.

Also, above and beyond rawdraw, you must implement the following two functions to handle when your apps is suspended, resumed or has its window terminated.

void HandleResume(); void HandleSuspend(); void HandleWindowTermination();

In addition to that, the syntax of HandleMotion(...) is different, in that instead of the mask variable being a mask, it is simply updating that specific pointer.

Google Play

As it turns out, Google somehow lets apps built with this onto the store. Like ColorChord https://github.com/cnlohr/colorchord.

Part 0: Changes to your app.

  1. Make sure you are using the newest SDK.
  2. You will need to add a versionCode to your AndroidManifest.xml. In your AndroidManifest.xml, add android:versionCode="integer" to the tag where "integer" is a version number.
  3. In your AndroidManifest.xml, change android:debuggable to false.
  4. You may want to support multiple platforms natively. Add the following to your Makefile: TARGETS:=makecapk/lib/arm64-v8a/lib$(APPNAME).so makecapk/lib/armeabi-v7a/lib$(APPNAME).so makecapk/lib/x86/lib$(APPNAME).so makecapk/lib/x86_64/lib$(APPNAME).so
  5. You will need to specify target and Min SDK in your AndroidManifest.xml See: <uses-sdk android:minSdkVersion="22" android:targetSdkVersion="28" />
  6. Those target / min versions must match your Makefile. Note that without a minSdkVerson google will wrongfully assume 1. This is dangerous. Be sure to test your app on a device with whichever minSdkVersion you've specified.
  7. You will need to disable the debuggable flag in your app. See <application android:debuggable="false" ...>

Get a google play account. Details surrounding app creation are outside the scope of this readme. When getting ready to upload your APK.

Keys: You will want a key for yourself that's a real key. Not the fake one.

First you will need to make a real key. This can be accomplished by deleting our fake key my-release-key.keystore and executing the following command (being careful to fill #### in with real info):

make keystore STOREPASS=#### DNAME="\"CN=####, OU=ID, O=####, L=####, S=####, C=####\"" ALIASNAME=####

The alias name will be standkey. You will want to verify you can build your app with this key. Be sure to fill in STOREPASS the same.

make clean run STOREPASS=####

Let Google create and manage my app signing key (recommended)

Export and upload a key and certificate from a Java keystore

If you want to use the play store key with "Export and upload a key and certificate from a Java keystore" Instead of Let Google create and manage my app signing key (recommended) and follow PEKP instructions.

Prepping your app for upload.

You MUST have aligned ZIPs for the Play store. You must run the following command:

zipalign -c -v 8 makecapk.apk

Upload your APK makecapk.apk made with your key.

Pre-SDK-32-Tools

If you are using Android 29 or older, do this.

yes | $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
$ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;29.0.3" "cmake;3.10.2.4988404" "ndk;21.1.6352462" "patcher;v4" "platform-tools" "platforms;android-30" "tools"

If your platform command-line tools are 30, the command-line tools will be placed in the cmdline-tools folder. So, you will need to execute the following:

yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
$ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;30.0.2" "cmake;3.10.2.4988404" "ndk;21.3.6528147" "patcher;v4" "platform-tools" "platforms;android-30" "tools"

If your platform command-line tools are 32, the command-line tools will be placed in the cmdline-tools folder. So, you will need to execute the following (This appears to be backwards compatbile to some degree with Android 30):

yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
$ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;32.0.0" "cmake;3.22.1" "ndk;25.1.8937393" "platforms;android-32" "patcher;v4" "platform-tools" "tools"

TODO

Try a bunch of these cool priveleges, see what they all do.

  • permission.ACCESS
  • permission.INTERNET
  • permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS
  • permission.ACCESS_NETWORK_STATE
  • permission.WRITE_EXTERNAL_STORAGE
  • permission.READ_PHONE_STATE
  • permission.GET_TASKS
  • permission.REORDER_TASKS
  • permission.WRITE_APN_SETTINGS
  • permission.READ_SECURE_SETTINGS
  • permission.READ_SETTINGS
  • permission.REAL_GET_TASKS
  • permission.INTERACT_ACROSS_USERS
  • permission.MANAGE_USERS
  • permission.INSTALL_PACKAGES
  • permission.DELETE_PACKAGES
  • permission.INTERACT_ACROSS_USERS_FULL
  • permission.READ_MEDIA_STORAGE
  • permission.WRITE_MEDIA_STORAGE
  • android.permission.VR
  • android.permission.INSTALL_PACKAGES

rawdrawandroid's People

Contributors

aefeinstein avatar cnlohr avatar davidventura avatar dependabot[bot] avatar dgramop avatar dreua avatar emmanuelmess avatar githubistoxic avatar graysuit avatar iamthecarl avatar ja2142 avatar jcd1230 avatar jgroman avatar kanth989 avatar nikkyai avatar pmp-p avatar rusomati avatar timgates42 avatar trevorah avatar znoctum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rawdrawandroid's Issues

Sound currently not working

@DavidVentura, for some reason apps crash when trying to initialize the sound under the current setup. I spent a bit trying to debug it, but I don't understand the code very well. Can you pull the latest everything then uncomment the call here, and see if it crashes for you?

//InitCNFAAndroid( Callback, "A Name", SAMPLE_RATE, 0, 1, 0, SAMPLE_COUNT, 0, 0, 0 );

Error when installing SDK and NDK

I tried to run the rawdrawandroidexample.

I tried "make" and then

ruvian@DESKTOP-M440L4C:~/rawdrawandroidexample$ make
mkdir -p makecapk/assets
echo "Test asset file" > makecapk/assets/asset.txt
rm -rf temp.apk
/home/ruvian/android-sdk/build-tools/29.0.3/aapt package -f -F temp.apk -I /home/ruvian/android-sdk/platforms/android-22/android.jar -M AndroidManifest.xml -S Sources/res -A makecapk/assets -v --target-sdk-version 28
Found 1 custom asset file in makecapk/assets
Configurations:
 (default)

Files:
  assets/asset.txt
    Src: () makecapk/assets/asset.txt
  mipmap/icon.png
    Src: () Sources/res/mipmap/icon.png
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type mipmap
    mipmap/icon.png
      Src: () Sources/res/mipmap/icon.png
Including resources from package: /home/ruvian/android-sdk/platforms/android-22/android.jar
W/asset   ( 4726): Asset path /home/ruvian/android-sdk/platforms/android-22/android.jar is neither a directory nor file (type=1).
ERROR: Asset package include '/home/ruvian/android-sdk/platforms/android-22/android.jar' not found.
make: *** [rawdrawandroid/Makefile:128: makecapk.apk] Error 1`

Then thought, ok, maybe if I try to reinstall from the beginning, so I did

ruvian@DESKTOP-M440L4C:~/rawdrawandroidexample$ $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "build-tools;29.0.3" "cmake;3.10.2.4988404" "ndk;21.1.6352462" "patcher;v4" "platform-tools" "platforms;android-24" "tools"
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 5 more

But errors again. I'm not that knowledged in these things, a friend of mine tried to help me, we got far, but I just don't know what to do now.

fatal error: 'os_generic.h' file not found

I strictly followed the guide; Android Sdk is in ~/Android/Sdk
make keystore works fine
make push run produces the following:

mkdir -p makecapk/lib/arm64-v8a
/home/archie/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang -ffunction-sections -Os -fdata-sections -Wall -fvisibility=hidden -Os -DANDROID -DAPPNAME=\"cnfgtest\" -I./rawdraw -I/home/archie/Android/Sdk/ndk/23.1.7779620/sysroot/usr/include -I/home/archie/Android/Sdk/ndk/23.1.7779620/sysroot/usr/include/android -I/home/archie/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android -fPIC -I. -DANDROIDVERSION=30 -m64 -o makecapk/lib/arm64-v8a/libcnfgtest.so test.c android_native_app_glue.c -L/home/archie/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/30 -Wl,--gc-sections -s -lm -lGLESv3 -lEGL -landroid -llog -shared -uANativeActivity_onCreate
test.c:8:10: fatal error: 'os_generic.h' file not found
#include "os_generic.h"
         ^~~~~~~~~~~~~~
1 error generated.
make: *** [Makefile:122: makecapk/lib/arm64-v8a/libcnfgtest.so] Error 1

SFML

Is there any way to use the SFML library?

Android 24 ?

Hello,

In the readme file it says to select Android 24, i cant seem to find that is it a mistype ?

thanks

Blimp

ASensorManager_getDefaultSensor returns NULL

I get this crash when the app starts (not modified):

07-24 22:30:23.221 24560 24576 D cnfgtest: Starting with Android SDK Version: 25Starting Main
07-24 22:30:23.221 24560 24576 D cnfgtest: Start: 0xab9179e0
07-24 22:30:23.223 24560 24576 D cnfgtest: activityState=10
07-24 22:30:23.228 24560 24576 D cnfgtest: event not handled: 10Resume: 0xab9179e0
07-24 22:30:23.228 24560 24576 D cnfgtest: activityState=11
07-24 22:30:23.248 24560 24576 D cnfgtest: event not handled: 11InputQueueCreated: 0xab9179e0 -- 0xab917b20
07-24 22:30:23.248 24560 24576 D cnfgtest: APP_CMD_INPUT_CHANGED
07-24 22:30:23.279  1158  8026 D InputDispatcher: Focus entered window: Window{7ee26fc u0 org.yourorg.cnfgtest/android.app.NativeActivity}
07-24 22:30:23.285 24560 24576 D cnfgtest: Attaching input queue to looperevent not handled: 0NativeWindowCreated: 0xab9179e0 -- 0xab97e008
07-24 22:30:23.285 24560 24576 D cnfgtest: APP_CMD_INIT_WINDOW
07-24 22:30:23.285 24560 24576 D cnfgtest: Got start event
07-24 22:30:23.292 24560 24576 D cnfgtest: WindowFocusChanged: 0xab9179e0 -- 1
07-24 22:30:23.295 24560 24576 D cnfgtest: EGL Version: "1.4 Android META-EGL"
07-24 22:30:23.295 24560 24576 D cnfgtest: EGL Vendor: "Android"
07-24 22:30:23.295 24560 24576 D cnfgtest: EGL Extensions: "EGL_KHR_get_all_proc_addresses EGL_ANDROID_presentation_time EGL_KHR_swap_buffers_with_damage EGL_ANDROID_create_native_client_buffer EGL_ANDROID_front_buffer_auto_refresh EGL_KHR_image EGL_KHR_image_base EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_fence_sync EGL_KHR_create_context EGL_KHR_config_attribs EGL_KHR_surfaceless_context EGL_EXT_create_context_robustness EGL_ANDROID_image_native_buffer EGL_KHR_wait_sync EGL_ANDROID_recordable EGL_KHR_partial_update "
07-24 22:30:23.295 24560 24576 D cnfgtest: Config: 1
07-24 22:30:23.295 24560 24576 D cnfgtest: Creating Context
07-24 22:30:23.299 24560 24576 D cnfgtest: Context Created 0xb1d24500
07-24 22:30:23.299 24560 24576 D cnfgtest: Getting Surface 0xab97e008
07-24 22:30:23.301 24560 24576 D cnfgtest: Width/Height: 720x1280
07-24 22:30:23.304 24560 24576 D cnfgtest: Got Surface: 0x958fc060
07-24 22:30:23.304 24560 24576 D cnfgtest: GL Vendor: "ARM"
07-24 22:30:23.305 24560 24576 D cnfgtest: GL Renderer: "Mali-T860"
07-24 22:30:23.305 24560 24576 D cnfgtest: GL Version: "OpenGL ES 3.2 v1.r12p0-04rel0.44f2946824bb8739781564bffe2110c9"
07-24 22:30:23.305 24560 24576 D cnfgtest: GL Extensions: "GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic GL_EXT_robustness GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed GL_EXT_texture_border_clamp GL_OES_texture_border_clamp GL_EXT_texture_cube_map_array GL_OES_texture_cube_map_array GL_OES_sample_variables GL_OES_sample_shading GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks GL_OES_shader_io_blocks GL_EXT_tessellation_shader GL_OES_tessellation_shader GL_EXT_primitive_bounding_box GL_OES_primitive_bounding_box GL_EXT_geometry_shader GL_OES_geometry_shader GL_ANDROID_exte
07-24 22:30:23.305 24560 24576 D cnfgtest: nsion_pack_es31a GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture_buffer GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2 GL_OVR_multiview_multisampled_render_to_texture GL_KHR_robustness GL_KHR_robust_buffer_access_behavior GL_EXT_draw_elements_base_vertex GL_OES_draw_elements_base_vertex "
07-24 22:30:23.328  1158  1230 I ActivityManager: Displayed org.yourorg.cnfgtest/android.app.NativeActivity: +274ms (total +15m25s592ms)
07-24 22:30:23.332  1158  1230 V WindowManager: Not removing Window{3bc34ff u0 Starting org.yourorg.cnfgtest EXITING} due to exit animation 
07-24 22:30:23.359 24593 24593 I AEE_AED : check process 24560 name:ourorg.cnfgtest
07-24 22:30:23.361 24593 24593 I AEE_AED : [preset_info] pid: 24560, tid: 24577, name: Thread-3  >>> org.yourorg.cnfgtest <<<
07-24 22:30:23.434 24593 24593 I AEE_AED : pid: 24560, tid: 24577, name: Thread-3  >>> org.yourorg.cnfgtest <<<
07-24 22:30:23.436 24593 24593 I AEE_AED :     #02 pc 00004570  /data/app/org.yourorg.cnfgtest-1/lib/arm/libcnfgtest.so
07-24 22:30:24.486 24593 24593 V AEE_AED : dashboard_record_update() : rec->module = org.yourorg.cnfgtest 
07-24 22:30:24.487  1158 24594 W ActivityManager:   Force finishing activity org.yourorg.cnfgtest/android.app.NativeActivity
07-24 22:30:24.503  1158 24594 D InputDispatcher: Focus left window: Window{7ee26fc u0 org.yourorg.cnfgtest/android.app.NativeActivity}
07-24 22:30:24.525  1158  1447 W InputDispatcher: channel '7ee26fc org.yourorg.cnfgtest/android.app.NativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
07-24 22:30:24.525  1158  1447 E InputDispatcher: channel '7ee26fc org.yourorg.cnfgtest/android.app.NativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
07-24 22:30:24.526  1158  4613 I WindowManager: WIN DEATH: Window{7ee26fc u0 org.yourorg.cnfgtest/android.app.NativeActivity}
07-24 22:30:24.526  1158  4613 W InputDispatcher: Attempted to unregister already unregistered input channel '7ee26fc org.yourorg.cnfgtest/android.app.NativeActivity (server)'
07-24 22:30:24.529  1158  4613 D InputDispatcher: Window went away: Window{7ee26fc u0 org.yourorg.cnfgtest/android.app.NativeActivity}
07-24 22:30:24.552  1158  1908 I ActivityManager: Process org.yourorg.cnfgtest (pid 24560) has died
07-24 22:30:24.613  1158  1210 D InputDispatcher: Focus entered window: Window{af4f2b4 u0 Application Error: org.yourorg.cnfgtest}
07-24 22:30:24.705  1158  1230 I WindowManager: Window{af4f2b4 u0 Application Error: org.yourorg.cnfgtest} start dimming: flags=1820002 effectFlags=0, layer=111000
07-24 22:30:24.717  1158  1230 I WindowManager: Window{af4f2b4 u0 Application Error: org.yourorg.cnfgtest} start dimming: flags=1820002 effectFlags=0, layer=111000

make uninstall; make push run Prints:

(adb uninstall org.yourorg.cnfgtest)||true
Success
mkdir -p makecapk/assets
echo "Test asset file" > makecapk/assets/asset.txt
rm -rf temp.apk
/home/emmanuel/Android/Sdk/build-tools/30.0.1/aapt package -f -F temp.apk -I ~/Android/Sdk/platforms/android-29/android.jar -M AndroidManifest.xml -S Sources/res -A makecapk/assets -v --target-sdk-version 29
Found 1 custom asset file in makecapk/assets
Configurations:
 (default)

Files:
  assets/asset.txt
    Src: () makecapk/assets/asset.txt
  mipmap/icon.png
    Src: () Sources/res/mipmap/icon.png
  values/strings.xml
    Src: () Sources/res/values/strings.xml
  AndroidManifest.xml
    Src: () AndroidManifest.xml

Resource Dirs:
  Type mipmap
    mipmap/icon.png
      Src: () Sources/res/mipmap/icon.png
  Type values
    values/strings.xml
      Src: () Sources/res/values/strings.xml
Including resources from package: /home/emmanuel/Android/Sdk/platforms/android-29/android.jar
applyFileOverlay for drawable
applyFileOverlay for layout
applyFileOverlay for anim
applyFileOverlay for animator
applyFileOverlay for interpolator
applyFileOverlay for transition
applyFileOverlay for xml
applyFileOverlay for raw
applyFileOverlay for color
applyFileOverlay for menu
applyFileOverlay for font
applyFileOverlay for mipmap
Processing image: Sources/res/mipmap/icon.png
    (processed image Sources/res/mipmap/icon.png: 100% size of source)
    (new resource id icon from mipmap/icon.png #generated)
Creating 'temp.apk'
Writing all files...
      'AndroidManifest.xml' (compressed 63%)
      'assets/asset.txt' (not compressed)
      'res/mipmap/icon.png' (not compressed)
      'resources.arsc' (not compressed)
Generated 4 files
Included 0 files from jar/zip files.
Checking for deleted files
Done!
unzip -o temp.apk -d makecapk
Archive:  temp.apk
  inflating: makecapk/AndroidManifest.xml  
 extracting: makecapk/assets/asset.txt  
 extracting: makecapk/res/mipmap/icon.png  
 extracting: makecapk/resources.arsc  
rm -rf makecapk.apk
cd makecapk && zip -D9r ../makecapk.apk .
  adding: AndroidManifest.xml (deflated 63%)
  adding: res/mipmap/icon.png (deflated 8%)
  adding: lib/arm64-v8a/libcnfgtest.so (deflated 59%)
  adding: lib/armeabi-v7a/libcnfgtest.so (deflated 52%)
  adding: assets/asset.txt (stored 0%)
  adding: resources.arsc (deflated 73%)
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -verbose -keystore my-release-key.keystore -storepass password makecapk.apk standkey
   adding: META-INF/MANIFEST.MF
   adding: META-INF/STANDKEY.SF
   adding: META-INF/STANDKEY.RSA
  signing: AndroidManifest.xml
  signing: res/mipmap/icon.png
  signing: lib/arm64-v8a/libcnfgtest.so
  signing: lib/armeabi-v7a/libcnfgtest.so
  signing: assets/asset.txt
  signing: resources.arsc

>>> Signer
    X.509, CN=example.com, OU=ID, O=Example, L=Doe, ST=John, C=GB
    [trusted certificate]

jar signed.

Warning: 
The signer's certificate is self-signed.
rm -rf cnfgtest.apk
/home/emmanuel/Android/Sdk/build-tools/30.0.1/zipalign -v 4 makecapk.apk cnfgtest.apk
Verifying alignment of cnfgtest.apk (4)...
      50 META-INF/MANIFEST.MF (OK - compressed)
     439 META-INF/STANDKEY.SF (OK - compressed)
     898 META-INF/STANDKEY.RSA (OK - compressed)
    2078 AndroidManifest.xml (OK - compressed)
    3023 res/mipmap/icon.png (OK - compressed)
    3194 lib/arm64-v8a/libcnfgtest.so (OK - compressed)
   19422 lib/armeabi-v7a/libcnfgtest.so (OK - compressed)
   35916 assets/asset.txt (OK)
   36000 resources.arsc (OK - compressed)
Verification succesful
rm -rf temp.apk
rm -rf makecapk.apk
-rw-rw-r-- 1 emmanuel emmanuel 37045 jul 24 22:14 cnfgtest.apk
Installing org.yourorg.cnfgtest
adb install cnfgtest.apk
Success
adb shell am start -n org.yourorg.cnfgtest/android.app.NativeActivity
Starting: Intent { cmp=org.yourorg.cnfgtest/android.app.NativeActivity }

I know C and Android (Java/Kotlin/Flutter), how should I go about fixing this?

README link to permissions request code 404s

In "If you are going to use this section", this link 404s:
https://github.com/cnlohr/colorchord/blob/master/colorchord2/sound_android.c

As far as I can tell, the relevant code is here:
https://github.com/cntools/cnfa/blob/d271e0196d81412032eeffa634a94a1aaf0060a7/CNFA_android.c#L305

int hasperm = AndroidHasPermissions( "RECORD_AUDIO" );
if( !hasperm )
{
	AndroidRequestAppPermissions( "RECORD_AUDIO" );
}

Also, if that's all the code, it might be helpful to put a little code block in the README.

Logcat spam (BufferQueueProducer) when suspended

Steps to reproduce:

  1. run adb logcat | grep cnfgtest
  2. run rawdrawandroid in another shell
  3. suspend the app, for example go to the homescreen
  4. Log is printing this message at a high rate:
07-25 01:28:34.392   469  3410 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer
07-25 01:28:34.409   469   507 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer
07-25 01:28:34.409   469  2856 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer
07-25 01:28:34.428   469   507 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer
07-25 01:28:34.429   469  2856 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer
07-25 01:28:34.446   469  3410 E BufferQueueProducer: [org.yourorg.cnfgtest/android.app.NativeActivity] dequeueBuffer: BufferQueue has no connected producer

When closing the app (via recent tasks) it stops. Not sure if this is specific to my Android version / device.

push & run aligned apk to device

A few suggestion:

  1. Currently, the Makefile installs and runs makecapk.apk, wouldn't it be better to replace that with aligned.apk?

  2. In my modified version of the Makefile I also added APK_NAME ?= $(APPNAME).apk variable to automatically name the final (aligned) .apk output.

  3. Wouldn't it also be cleaner to delete temp.apk and makecapk.apk (or at least the former) after a successful build? I think it would avoid confusion.

  4. I would also replace echo with @echo to make the output a slight bit easier to parse by eye.

makefile fails to detect NDK directory

Hi,
The Makefile fails to detect the NDK directory on my machine (Linux Mint 19 Cinnamon), with Android Studio 3.6.1 . The NDK when installed via Android Studio SDK Manager, is located in "~ /Android/Sdk/ndk-bundle/", not "~/Android/Sdk/ndk/". Ran into some other issues as well, but they seem to be fixed already yesterday.

Awesome work by the way, keep up the good work!

Error while running my own C code. App closes.

Hello,
I downloaded the git and wanted to learn from scratch. While search online, i found the "hello-jni.c" Android NDK's example c program for JNI. I followed all the steps in the readme and i was able to load the the default test app and the app works. but when i try to do the same for the hello.c , the app closes.

and i get the following error when i do adb logcat | grep UnsatisfiedLinkError :

.... 12517:05-20 11:23:45.806 32051 32051 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/org.yourorg.hello-edwqrnIee8oo7b-A2D2ggw==/lib/arm64/libhello.so": dlopen failed: cannot locate symbol "android_main" referenced by "/data/app/org.yourorg.hello-edwqrnIee8oo7b-A2D2ggw==/lib/arm64/libhello.so"... ......

the code : https://github.com/android/ndk-samples/blob/master/hello-jni/app/src/main/cpp/hello-jni.c

Thanks

Typos on Makefile and app crash

Hi,

I'm trying to compile rawandroid under WSL following the excellent guidelines but in the makefile:

  • ANDROIDVERSION is set to 29 but should be 24.
  • in the AndroidManifest.xml part, "PACKAGENAME=$(PACKAGENAME)" is missing and under WSL envsubst do not works! It fills with empty strings! (Any hint ?? )

Then, when I fix this small issues, the uploaded application keeps crashing, last string I see after "make run" is: Starting: Intent { cmp=org.yourorg.cnfgtest/android.app.NativeActivity }

Thank you for your time.

adb fails to collect certificates, even if `make keystore` has already been run

I'm using the Terminator terminal on Arch Linux. The Java development kit is installed, Android Studio is installed and I followed the setup instructions up until this command below.

Command:
make push run

Output:

echo "Installing" org.yourorg.cnfgtest
Installing org.yourorg.cnfgtest
adb install makecapk.apk
Performing Streamed Install
adb: failed to install makecapk.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl807465674.tmp/base.apk: Attempt to get length of null array]
make: *** [Makefile:143: push] Error 1

http requests

Hi,

I would like to get internet connection with this project. I tried compile curl with ndk, but gave errors. I can get simple http requests with this library: https://github.com/mattiasgustavsson/libs/blob/main/http.h but I want to have https.

Now I try to to use jni to make java calls to urlconnection, my code so far:

        const struct JNINativeInterface * env = 0;
        const struct JNINativeInterface ** envptr = &env;
        const struct JNIInvokeInterface ** jniiptr = app->activity->vm;
        const struct JNIInvokeInterface * jnii = *jniiptr;
        jnii->AttachCurrentThread( jniiptr, &envptr, NULL);
        env = (*envptr);

        // Retrieves NativeActivity.
        jobject lNativeActivity = gapp->activity->clazz;

        // URL url = new URL(urlString);
        jclass ClassContext = env->FindClass( envptr, "java/net/URL" );
        jmethodID urlConstructor = env->GetMethodID( envptr, ClassContext, "<init>", "(Ljava/lang/String;)V");
        const char url[50] = "http://httpbin.org/anything";
        jstring jurl = env->NewStringUTF( envptr, "http://httpbin.org/anything" );
        jstring jget = env->NewStringUTF( envptr, "GET" );
        jobject urlObj = env->NewObject( envptr, ClassContext, urlConstructor, jurl );

        // urlConnection = (HttpURLConnection) url.openConnection();
        jmethodID openConn = env->GetMethodID( envptr, ClassContext, "openConnection", "()Ljava/net/URLConnection;");
        jobject urlConnectionObj = env->CallObjectMethod( envptr, urlObj, openConn );

        // urlConnection.setRequestMethod("GET");
        jclass urlClass = GetObjectClass( envptr, urlConnectionObj );//env->FindClass( envptr, "java/net/HttpURLConnection" );
        jmethodID setRequestMethod = env->GetMethodID( envptr, urlClass, "setRequestMethod", "(Ljava/lang/String;)V");
        env->CallObjectMethod( envptr, urlConnectionObj, setRequestMethod, jget );

But this code is really not complete and gives errors (I have no idea why).

If anyone tried something similar like this, what did you use? Also where could I learn jni commands? If i get success in this I promise to share.

It can be amazing to get network apps like chat can be under 50kb.

Sorry for bad english

And what about Android accessibility suite support

Do you think, that there could be some complex C language routine, which would allow developers to create fully accessible GUi even for Android accessibility suite users? Or unfortunately, GUI compatible with Explore by touch Android service and with Android accessibility suite can not be done by this way?

You are C language expert, so I AM giving you this question.

App flashes quickly when trying to open it (dlopen failed: cannot locate symbol "example_log_function")

Hey there, great project. I tested it by cloning the repo first and got it to work fine. Then I tried making my own project using rawdrawandroid as a submodule and when the app installs it flashes quickly and closes every time I try to open it.

By running adb logcat | grep UnsatisfiedLinkError I managed to get the following error:

E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/org.inloco.Funcional-qlzudJ1NlM5TiULMRAIWLA==/lib/arm64/libFuncional.so": dlopen failed: cannot locate symbol "example_log_function" referenced by "/data/app/org.inloco.Funcional-qlzudJ1NlM5TiULMRAIWLA==/lib/arm64/libFuncional.so"...

There's an old closed issue where some other guy had apparently the same problem I do, but I didn't see anything helpful there.

Is there any way you can help me, please? I've already checked that the include paths are correctly set in the makefile even though I'm calling make from one directory up rawdrawandroid, so I'm really at a loss, especially since I have no idea where "example_log_function" is from.

IllegalArgumentException: Unable to load native library

Hi,
I'm trying to run this code on my old Asus phone (Android 6.0.1). App window immediately closes, logcat shows this:

07-17 18:13:46.638 10951 10951 D AndroidRuntime: Shutting down VM
07-17 18:13:46.638 10951 10951 E AndroidRuntime: FATAL EXCEPTION: main
07-17 18:13:46.638 10951 10951 E AndroidRuntime: Process: org.yourorg.cnfgtest, PID: 10951
07-17 18:13:46.638 10951 10951 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.yourorg.cn
fgtest/android.app.NativeActivity}: java.lang.IllegalArgumentException: Unable to load native library: /data/app/org.yourorg.cnfgt
est-1/lib/arm/libcnfgtest.so
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:24
35)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:249
5)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread.access$900(ActivityThread.java:154)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:153)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5472)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.j
ava:726)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
07-17 18:13:46.638 10951 10951 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Unable to load native library: /da
ta/app/org.yourorg.cnfgtest-1/lib/arm/libcnfgtest.so
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.NativeActivity.onCreate(NativeActivity.java:182)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.Activity.performCreate(Activity.java:6323)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1
108)
07-17 18:13:46.638 10951 10951 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:23
88)

My setup:

export ANDROID_HOME=~/android/android-sdk-linux
export NDK=~/android/android-ndk-r21d

386 and amd64 (x86 and x64)

well I know that it is horrible request, but android has two other architectures, would it be possible to some easy way to add these architectures?

I ask because verry often simulators of android is x64 or x86 ...

( 2621): Asset path /root/android-sdk/platforms/android-29/android.jar is neither a directory nor file (type=1). In windows Linux WSL

Resource Dirs:
Type mipmap
mipmap/icon.png
Src: () Sources/res/mipmap/icon.png
Type values
values/strings.xml
Src: () Sources/res/values/strings.xml
Including resources from package: /root/android-sdk/platforms/android-29/android.jar
W/asset ( 2621): Asset path /root/android-sdk/platforms/android-29/android.jar is neither a directory nor file (type=1).
ERROR: Asset package include '/root/android-sdk/platforms/android-29/android.jar' not found.
Makefile:125: recipe for target 'makecapk.apk' failed
make: *** [makecapk.apk] Error 1

CI broken

@dreua any chance you could look at why the CI is broken? The error is nonobvious to me.

Love your project too much! Need some examples

I want to make idm like downloader using your project, but i cant see any example of uses http request, app design, menu add etc. Plz give me an example, i will be happy. Also keep updating your project, one day it will be popular. People cant reverser app and cant see any java. add lib encrypt system for more security.

I will add your project in my programming language in future. waiting for your good answer and examples. Love you ๐Ÿ˜

Issue with texture wrapping

Image is being wrapped when correct size is given.

when imgWidth = 320 and imgHeight = 240
CNFGBlitImage(current_image, (screenx/2) - (imgWidth/2), (screeny/2) - (imgHeight/2), imgWidth, imgHeight, 4);

I added a comp input to CNFGBlitImage for RGB and RGBA.

I am new to opengl, so I'm a bit lost as to what is causing this.

example screenshot of issue.
Screenshot_20220901-120606

error: unknown target CPU 'intel' NixOS

i composed an android packages (SDK) with the following versions on NixOS

  abiVersions = [ "armeabi-v7a" "arm64-v8a" "x86" "x86_64" ];
  platformVersions = [ "26" ];
  platformToolsVersion = "34.0.5";
  toolsVersion = "26.1.1";
  buildToolsVersions = [ "30.0.3" ];

see full configuration

after makeing it work for arm i tried uncommenting lines for make it available for x86 or x86_64 cpu but it give me this error with the composition previously declared.

error: unknown target CPU 'intel'
(for bot x86 and x86_64)

WORKAROUND
i figured out that removing the flag -mtune=intel seem to compile properly ( not still tested )

Commands to install for Windows are not working

In the part 3 of "rest of steps", I tried the command and it can't find the file, ok. Added .bat to the command and it finds it, but doesn't recognise internal file commands. Here goes:

ruvian@DESKTOP-M440L4C:/android-sdk/tools/bin$ yes | $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
-bash: /home/ruvian/android-sdk/tools/bin/sdkmanager: No such file or directory
ruvian@DESKTOP-M440L4C:/android-sdk/tools/bin$ yes | $ANDROID_HOME/tools/bin/sdkmanager.bat --sdk_root=${ANDROID_HOME} --licenses
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 1: @if: command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 2: @Rem: command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 3: $'@Rem\r': command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 4: @Rem: command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 5: $'@Rem\r': command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 6: @Rem: command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 7: $'\r': command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 8: @Rem: command not found
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 82: unexpected EOF while looking for matching `"'
/home/ruvian/android-sdk/tools/bin/sdkmanager.bat: line 85: syntax error: unexpected end of file

old java version in README

when I run

yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses

with java 11, as said by the docs, but i got the error

Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
	java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

I was able to resolve the issue by installing java 17 (I think that's what fixed it)

Error 1 when reinstalling

The app installs, instacrashes, and when I tried to rerun it:

adb install cnfgtest.apk
adb: failed to install cnfgtest.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install org.yourorg.cnfgtest without first uninstalling.]
make: *** [Makefile:167: push] Error 1

make clean and retrying doesn't work.

Phone LG K11 alpha
Android 7.1.2

How did you know that you could make this work without a `classes.dex` file?

I tried this project, and it worked extremely well on my phone with minimal setup. I have spent a few days looking at the code for the project, and learning about the Android build system, and I feel like you have come to such a great length in order to remove all instances of Java code. But I am wondering, how you knew that you could make an APK without any .dex file? In this script and this other script, both create Java files to convert to classes in order to convert them into .dex files, in order to have a classes.dex file in the APK. When I look up information about the classes.dex file, it seems to be "necessary", in order to run an application. But somehow, you were able to make a process that did not ever made a .dex file, yet still have a working Android application! The only actual binary file in the APK is the libcnfgtest.so file that was compiled from all the C files. I am asking how you were able to make this work, despite there being no information on the Internet that it ever could work. Is there some website I am not looking at? Please let me know.

package="${PACKAGENAME}" is left in AndroidManifest.xml

Following the instructions I ran

make push run

after which I saw the following error message:

AndroidManifest.xml:2: Tag <manifest> attribute package has invalid character '$'.

It looks like a variable package="${PACKAGENAME}" was left un-replaced from the template.

looking at the Makefile:

	envsubst '$$ANDROIDTARGET $$ANDROIDVERSION $$APPNAME $$LABEL' \
		< AndroidManifest.xml.template > AndroidManifest.xml

it doesn't look like the package name is added for substitution.

Unable to load native library ... is 64-bit instead of 32 bit

I was curios and tried to make this work but I'm struggling to fix this error:
05-12 23:39:27.783 22959 22959 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/org.yourorg.cnfgtest-1/lib/arm/libcnfgtest.so": dlopen failed: "/data/app/org.yourorg.cnfgtest-1/lib/arm/libcnfgtest.so" is 64-bit instead of 32-bit
Android displays that App crashed.
I tried so far: API 24 (btw: needs change in Manifest to work: remove android:requestLegacyExternalStorage="true") -> Same result

History

First I got this error on make push run:

echo "Installing" org.yourorg.cnfgtest
Installing org.yourorg.cnfgtest
adb install makecapk.apk
adb: failed to install makecapk.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
make: *** [Makefile:128: push] Error 1

I could fix it by setting TARGETS?=makecapk/lib/armeabi-v7a/lib$(APPNAME).so (My uname -a says its armv7l not sure what that means or if that is the correct way of checking my phones ABI though.)

Debugging in general

While I will outline a specific issue being faced, I'm really mostly interested in knowing how to debug a barebones project like this.

Should we use ndk-gdb somehow? (From initial testing I get the feeling this is not the approach.)
It throws an error Failed to retrieve application ABI from Android.mk.

Or perhaps running am from an adb shell, presumably using set-debug-app and -w to wait for a debugger; then using plain old gdb with gdbserver.

Other?

I just wanted to get some advice if possible before I potentially go digging down some unnecessary rabbit holes.


Currently just trying to get the example code working, so I can then poke around and develop a good understanding of how things are working.

Sideloading onto a device using Android 10 (API 29).

Can get the demo to startup on the device, I see a couple of seconds of content, then it crashes.

logcat yields the following (with the errors singled out).
The standout error being:

08-03 05:41:34.628   869   869 E Layer   : [Surface(name=AppWindowToken{3e549b token=Token{abc50aa ActivityRecord{da98795 u0 org.foo.quicktest/android.app.NativeActivity t235}}})/@0xdffaabd - animation-leash#0] No local sync point found
08-03 05:41:34.022  5387  5411 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.foo.quicktest/android.app.NativeActivity bnds=[439,1146][640,1409]} from uid 10132
08-03 05:41:34.087  5387  5466 I ActivityManager: Start proc 14945:org.foo.quicktest/u0a204 for activity {org.foo.quicktest/android.app.NativeActivity}
08-03 05:41:34.095 14945 14945 I chatty  : uid=10204(org.foo.quicktest) expire 6 lines
08-03 05:41:34.237 14945 14968 I chatty  : uid=10204(org.foo.quicktest) expire 31 lines
08-03 05:41:34.269 14945 14969 I chatty  : uid=10204(org.foo.quicktest) expire 5 lines
08-03 05:41:34.285  5387  5464 I ActivityTaskManager: Displayed org.foo.quicktest/android.app.NativeActivity: +262ms
08-03 05:41:34.451 14945 15001 I chatty  : uid=10204(org.foo.quicktest) expire 1 line
08-03 05:41:34.471  5387  5466 I ActivityManager: Start proc 15014:com.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0/u0i7 for  {org.foo.quicktest/org.chromium.content.app.SandboxedProcessService0:0}
08-03 05:41:34.498 14945 14998 I chatty  : uid=10204(org.foo.quicktest) expire 2 lines
08-03 05:41:34.570 14945 15000 I chatty  : uid=10204(org.foo.quicktest) expire 21 lines

08-03 05:41:34.628   869   869 E Layer   : [Surface(name=AppWindowToken{3e549b token=Token{abc50aa ActivityRecord{da98795 u0 org.foo.quicktest/android.app.NativeActivity t235}}})/@0xdffaabd - animation-leash#0] No local sync point found

08-03 05:41:34.673 14945 14981 I chatty  : uid=10204(org.foo.quicktest) expire 254 lines
08-03 05:41:34.955 15062 15062 I chatty  : uid=10204(org.foo.quicktest) /system/bin/app_process64 identical 1 line
08-03 05:41:35.195 14945 14981 F libc    : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 14981 (Thread-3), pid 14945 (.foo.quicktest)
08-03 05:41:35.345 15077 15077 F DEBUG   : pid: 14945, tid: 14981, name: Thread-3  >>> org.foo.quicktest <<<
08-03 05:41:35.351 15077 15077 F DEBUG   :       #08 pc 00000000000096a4  /data/app/org.foo.quicktest-z63IAQZUKcj_BhprsVvQ5A==/lib/arm64/libquicktest.so
08-03 05:41:35.685  5387 15080 W ActivityTaskManager:   Force finishing activity org.foo.quicktest/android.app.NativeActivity
08-03 05:41:35.742  5387  5880 W InputDispatcher: channel '127ffac org.foo.quicktest/android.app.NativeActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9

08-03 05:41:35.743  5387  5880 E InputDispatcher: channel '127ffac org.foo.quicktest/android.app.NativeActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

08-03 05:41:35.745  5387 10078 I ActivityManager: Process org.foo.quicktest (pid 14945) has died: fore TOP 
08-03 05:41:35.746  5387 12904 I WindowManager: WIN DEATH: Window{127ffac u0 org.foo.quicktest/android.app.NativeActivity}
08-03 05:41:35.746  5387 12904 W InputDispatcher: Attempted to unregister already unregistered input channel '127ffac org.foo.quicktest/android.app.NativeActivity (server)'

can this work in cygwin

would possible to use this from cygwin? because i want to try it... but it must work from windows 7 32bit... otherwise it's pointless

Failed to install no matching abis

When installing in a AVD with android API 24 I get:

adb: failed to install cnfgtest.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]

Ideas?

requestLegacyExternalStorage fails for older SDK versions

AndroidManifest.xml:3: error: No resource identifier found for attribute 'requestLegacyExternalStorage' in package 'android'

Deleting that part from the xml fixes it. I don't have enough knowledge around Android to know if you can just remove it without consequences. Try on a few SDK versions below 29. Currently on 24 and it fails.

Btw this project is amazing. Every few years I google 'Android + C` and everyone says it's impossible. Heh.

Redirect printf at start.

I.e. do the dup thing colorchord does, but at start instead of making the app do it.

Also, merge some of that functionality with native_app_glue.

How can I change the default font of rawdrawandroid?

Is it possible to change the font of rawdrawandoid to some of modern fonts like Poppins, Ubuntu, etc. If yes, how can i do it. The current font is awsome for games but for a minimal app, modern fonts like Poppins are more preferred, so please guide me to change it.

How to use Java classes in the JNI as an Android NativeActivity

You can create a java class:

package org.yourorg.cnfgtest;
import android.app.NativeActivity;
public class MyOtherNativeActivity extends android.app.NativeActivity {}

Then you can compile it into your project as a dex.

javac -source 1.7 -target 1.7 -d bin/org/yourorg/cnfgtest/ -classpath /home/charlesl/android-sdk/platforms/android-30/android.jar -sourcepath src src/org/yourorg/cnfgtest/MyOtherNativeActivity.java
~/android-sdk/build-tools/30.0.2/dx --output=makecapk/ --dex ./bin

And make sure your bin is in the main project (rawdrawandroid does this by default)

You will need to create your java class, then create a Dalvak Class Loader

 	jclass DexClassLoaderClass = env->FindClass( envptr, "dalvik/system/DexClassLoader" );
 	jmethodID DexClassLoaderConstructorID =  env->GetMethodID( envptr, DexClassLoaderClass,
 		"<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V" );
	jobject activity = gapp->activity->clazz;
	jclass activityClass = env->GetObjectClass(envptr, activity);
	jmethodID classLoaderID = env->GetMethodID( envptr, activityClass, "getClassLoader", "()Ljava/lang/ClassLoader;" );
	jclass appInfoClass = env->FindClass( envptr, "android/content/pm/ApplicationInfo" );
	jmethodID getAppInfo = env->GetMethodID( envptr, activityClass, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;" );
	jobject appInfo = env->CallObjectMethod( envptr, activity, getAppInfo );
	jfieldID sourceDirID = env->GetFieldID( envptr, appInfoClass, "sourceDir", "Ljava/lang/String;" );
	jfieldID dataDirID = env->GetFieldID( envptr, appInfoClass, "dataDir", "Ljava/lang/String;" );
	jfieldID nativeLibraryDirID = env->GetFieldID( envptr, appInfoClass, "nativeLibraryDir", "Ljava/lang/String;" );
	jobject  sourceDir = env->GetObjectField( envptr, appInfo, sourceDirID );
	jobject  dataDir = env->GetObjectField( envptr, appInfo, dataDirID );
	jobject  nativeLibraryDir = env->GetObjectField( envptr, appInfo, nativeLibraryDirID );
	jobject classLoader = env->CallObjectMethod( envptr, activity, classLoaderID );
	printf( "CL: %p\n", classLoader );
 	jobject dcl = env->NewObject( envptr, DexClassLoaderClass, DexClassLoaderConstructorID, 
 		sourceDir, dataDir, nativeLibraryDir, classLoader );
 	printf( "DCL********************* %p\n", dcl );
	jclass dclClass = env->GetObjectClass( envptr, dcl );
	jmethodID loadClassID = env->GetMethodID( envptr, dclClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;" );

From there, you can just

	//loadClass( java.lang.String ) -> java.lang.Class<?>
	jmethodID loadClassID = env->GetMethodID( envptr, dclClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;" );
// DexClassLoader(String dexPath, String optimizedDirectory, String librarySearchPath, ClassLoader parent) 
	jstring myClassName = env->NewStringUTF( envptr,  "src/org/yourorg/cnfgtest/MyOtherNativeActivity" );
	jclass AccessoryClass = env->CallObjectMethod(envptr, dcl, loadClassID, myClassName );
//DumpObjectClassProperties( AccessoryClass );

Voila! Easy Peasy. ๐Ÿ™„

Using An Alternative to Rawdraw, such as SDL + OpenGL ES?

Basically, I was just wondering if I have to use rawdraw for this. I have an application that uses SDL2 for things like GUI and Window management, threading, and interfacing with OpenGL ES. If I am able to use stuff like SDL2, how (in general) would I go about doing that?

Parser error: there was a problem parsing the package

Hello. I've tried to build/push the sample app into my android phone(android 6, not rooted!)

But in final step, it throws some errors on my screen phone.
These are last lines of build process:

Verification succesful
#Using the apksigner in this way is only required on Android 30+
/mnt/D/software/linux/IDE/android/sdk/build-tools/30.0.0/apksigner sign --key-pass pass:password --ks-pass pass:password --ks my-release-key.keystore cnfgtest.apk
rm -rf temp.apk
rm -rf makecapk.apk
-rwxrwxrwx 1 linarcx root 45823 Jan  1 11:19 cnfgtest.apk
Installing org.yourorg.cnfgtest
adb install -r cnfgtest.apk
Performing Push Install
cnfgtest.apk: 1 file pushed, 0 skipped. 2.5 MB/s (45823 bytes in 0.017s)
        pkg: /data/local/tmp/cnfgtest.apk

Notice that i set ANDROIDVERSION?=28 in Makefile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.