Welcome to Android!

There are a couple features of Android to be concerned.
By default Android devices detect orientation change. Doing this android destroys previous layout and redraws the new one with another orientation. So while browsing through JuceDemo one can experience unexpected things when orientation is changed. The Activity is completely recreated from scratch and all its state is cleared and the very first page is rendered to user. Basically you should save the state of activity in onPause method and restore it in onResume but it is some kind of a challenge :slight_smile:

Audio Demo falls in exception ERROR/AndroidRuntime(7287): java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.

And it seems that Android Canvas Render option is not yet working. In “software render” mode it takes about 80% of CPU (800Mhz arm 6tj) to render “linear gradient” with “animate position” and “higher quality interpolation” that seems too much. I guess google suggests OpenGL ES as low-level API to Android’s graphic layer

Jules, I wish you all the very best of LUCK with Android :slight_smile: The challenge is great!

Yes, screen rotation is on my to-do-list!

I actually spent almost a week writing the canvas renderer, before finding out that it doesn’t provide anti-aliased clipping to paths, or clipping to image alpha channels, so it essentially useless… (It was also slow, not much better than the software renderer in my tests). I’ve put the software renderer in place for now, but I think the only workable long-term solution is to write an openGL ES renderer instead. As mentioned on another thread, if any experienced openGL devs want to volunteer for that job, I’d be happy to pay for it.

[quote=“skopus”]It is not possible to build JuceDemo on Windows(XP) with current Android.mk due to maximum path/filename limits

But it is possible with the following changes:

  • Add to Adroid.mk
    LOCAL_C_INCLUDES :=
    …/…/…/amalgamation
    …/…/…/…/…/amalgamation\
  • Make a corresponding replace in JuceLibraryCodexx.cpp like
    //#include “…/…/…/amalgamation/juce_amalgamated1.cpp”
    #include “juce_amalgamated1.cpp”

I am sure these changes will prevent the project from building on other platforms. So keep it in mind or use conditional compilation directives

Anyway i am happy to know that the excelent Juce library is not ignoring this popular (but yet uncomfortable for a developer) platform[/quote]

Thanks for the trick. That worked, but I’m still getting a runtime error when the package is deployed on the virtual device:

05-29 08:05:23.198: ERROR/AndroidRuntime(349): FATAL EXCEPTION: main 05-29 08:05:23.198: ERROR/AndroidRuntime(349): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.juce/com.juce.JuceAppActivity}: java.lang.ClassNotFoundException: com.juce.JuceAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.juce-1.apk] 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1544) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.os.Handler.dispatchMessage(Handler.java:99) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.os.Looper.loop(Looper.java:123) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread.main(ActivityThread.java:3647) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at java.lang.reflect.Method.invokeNative(Native Method) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at java.lang.reflect.Method.invoke(Method.java:507) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at dalvik.system.NativeStart.main(Native Method) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): Caused by: java.lang.ClassNotFoundException: com.juce.JuceAppActivity in loader dalvik.system.PathClassLoader[/data/app/com.juce-1.apk] 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1536) 05-29 08:05:23.198: ERROR/AndroidRuntime(349): ... 11 more 05-29 08:05:23.221: WARN/ActivityManager(60): Force finishing activity com.juce/.JuceAppActivity 05-29 08:05:24.278: WARN/ActivityManager(60): Activity pause timeout for HistoryRecord{406a0220 com.juce/.JuceAppActivity} 05-29 08:05:28.409: INFO/Process(349): Sending signal. PID: 349 SIG: 9 05-29 08:05:28.448: WARN/InputManagerService(60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4054c7c0 05-29 08:05:28.749: INFO/ActivityManager(60): Process com.juce (pid 349) has died. 05-29 08:05:35.488: WARN/ActivityManager(60): Activity destroy timeout for HistoryRecord{406a0220 com.juce/.JuceAppActivity}

Did you make any changes in the AndroidManifest file?

I finally managed to run the Android demo app on Windows, though I had to manually import the ComponentPeerView and JuceAppActivity classes in my project, as the “voodoo” (it’s still some kind of magic for me;-) link wouldn’t work.

I just have an additional question. With the current version can we build a Juce Android app for a 2.1 (version 7) target? When I try changing the version on my app, it just shuts down immediately and I can see the following log:

06-11 09:10:39.505: INFO/ActivityManager(64): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.juce/.JuceAppActivity } 06-11 09:10:39.595: INFO/ActivityManager(64): Start proc com.juce for activity com.juce/.JuceAppActivity: pid=404 uid=10028 gids={3003, 1015} 06-11 09:10:39.925: DEBUG/ddm-heap(404): Got feature list request 06-11 09:10:40.245: DEBUG/dalvikvm(404): Trying to load lib /data/data/com.juce/lib/libjuce_jni.so 0x43d0c6d0 06-11 09:10:40.596: INFO/DEBUG(28): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 06-11 09:10:40.596: INFO/DEBUG(28): Build fingerprint: 'generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys' 06-11 09:10:40.596: INFO/DEBUG(28): pid: 404, tid: 404 >>> com.juce <<< 06-11 09:10:40.596: INFO/DEBUG(28): signal 4 (SIGILL), fault addr 81000000 06-11 09:10:40.596: INFO/DEBUG(28): r0 817cb9e0 r1 81346b09 r2 afe0fa18 r3 afe0fa18 06-11 09:10:40.596: INFO/DEBUG(28): r4 817ba164 r5 bea5a714 r6 00000000 r7 00000001 06-11 09:10:40.605: INFO/DEBUG(28): r8 ad00f380 r9 0000bd00 10 4104bc44 fp 00000000 06-11 09:10:40.605: INFO/DEBUG(28): ip 817ba268 sp bea5a6f8 lr 81346b95 pc 81000000 cpsr a0000010 06-11 09:10:40.706: INFO/DEBUG(28): #00 pc 00000000 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.716: INFO/DEBUG(28): #01 pc 00346b92 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.716: INFO/DEBUG(28): code around lr: 06-11 09:10:40.716: INFO/DEBUG(28): 81346b84 d0052b00 49124811 44794478 ea52f631 06-11 09:10:40.726: INFO/DEBUG(28): 81346b94 447b4b10 4b0c6818 2b0058e3 f631d010 06-11 09:10:40.726: INFO/DEBUG(28): 81346ba4 2800ea2c 2004d00c ff9cf7fe 58e34b0a 06-11 09:10:40.726: INFO/DEBUG(28): stack: 06-11 09:10:40.726: INFO/DEBUG(28): bea5a6b8 bea5a7c8 [stack] 06-11 09:10:40.726: INFO/DEBUG(28): bea5a6bc b000f448 /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6c0 b000fd00 /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6c4 817ba094 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6c8 00000000 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6cc b00004ef /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6d0 b00163d0 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6d4 b000f448 /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6d8 b000fd00 /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6dc 817ba094 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6e0 00000000 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6e4 b0000559 /system/bin/linker 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6e8 00000000 06-11 09:10:40.736: INFO/DEBUG(28): bea5a6ec 00000000 06-11 09:10:40.745: INFO/DEBUG(28): bea5a6f0 df002777 06-11 09:10:40.745: INFO/DEBUG(28): bea5a6f4 e3a070ad 06-11 09:10:40.745: INFO/DEBUG(28): #01 bea5a6f8 817c6ab4 06-11 09:10:40.745: INFO/DEBUG(28): bea5a6fc 817ba164 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.745: INFO/DEBUG(28): bea5a700 00000000 06-11 09:10:40.755: INFO/DEBUG(28): bea5a704 81346d7f /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.755: INFO/DEBUG(28): bea5a708 bea5a784 [stack] 06-11 09:10:40.755: INFO/DEBUG(28): bea5a70c b000fad0 /system/bin/linker 06-11 09:10:40.755: INFO/DEBUG(28): bea5a710 afe42ad4 06-11 09:10:40.755: INFO/DEBUG(28): bea5a714 073c3a01 06-11 09:10:40.765: INFO/DEBUG(28): bea5a718 00000000 06-11 09:10:40.765: INFO/DEBUG(28): bea5a71c 817ba164 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.775: INFO/DEBUG(28): bea5a720 817c64f8 06-11 09:10:40.775: INFO/DEBUG(28): bea5a724 00000000 06-11 09:10:40.775: INFO/DEBUG(28): bea5a728 00000001 06-11 09:10:40.775: INFO/DEBUG(28): bea5a72c 81344935 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:40.775: INFO/DEBUG(28): bea5a730 00000000 06-11 09:10:40.775: INFO/DEBUG(28): bea5a734 b00041d9 /system/bin/linker 06-11 09:10:40.775: INFO/DEBUG(28): bea5a738 ffffffff 06-11 09:10:40.785: INFO/DEBUG(28): bea5a73c 817ba164 /data/data/com.juce/lib/libjuce_jni.so 06-11 09:10:41.385: DEBUG/Zygote(30): Process 404 terminated by signal (4) 06-11 09:10:41.395: INFO/ActivityManager(64): Process com.juce (pid 404) has died. 06-11 09:10:41.426: INFO/UsageStats(64): Unexpected resume of com.android.launcher while already resumed in com.juce 06-11 09:10:41.536: WARN/InputManagerService(64): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43db4e00 06-11 09:21:00.286: DEBUG/dalvikvm(64): GC freed 16441 objects / 853208 bytes in 205ms 06-11 09:22:56.866: DEBUG/dalvikvm(117): GC freed 8722 objects / 465624 bytes in 124ms

I could of course target 2.3.1 (version 9), but I’d like to be as compatible as possible (for instance I have version 2.1 on my own mobile).

From the stack trace, my guess is that the google build tools must be linking something into the DLL that isn’t available on 2.1, and that’s why the DLL won’t load. Not sure what could be done about that - it’s not possible to build using an older version of the Android SDK, because only the latest one actually supports c++!

I see. But do you manage to build a 2.1 app on Mac? I could just switch platforms.

I haven’t tried doing a 2.1 build TBH. I suspect that it’s probably not possible with the later SDKs, but I could be wrong.

You were right. And fortunately they seem to have corrected the problem in the latest NDK r5c version just released:

[quote]# Fixed a bug where code linked against gnustl_static crashed when run on platform releases older than API level 8 (Android 2.2).
[/quote]

I’ll see if it works and confirm.

Hi Gents,

I’m new to Juce and I’m working on a new Android project that needs to use Juce (the iPhone version uses Juce). I’m trying to follow the instructions (in juce/docs/readme.html) for building Juce for Android, but I’m getting nowhere. According to the instructions I should create a new project with IntroJucer, which I could open with Eclipse. I create a new project (Console Application type, not sure). I expected to see an Android subdirectory in my-proj/Builds, but nothing was created.
Could someone pointed me the quick steps to create an Android project in Juce? Thanks in advance.

Cheers,
Isaac

It’d need to be a “GUI app”, not a console app - and then you’d need to create an Android exporter target (use the button at the bottom of the introjucer’s project info page)

Thanks, Jules.
Now, I’m on the right track. :smiley:

Cheers

Hi Jules,
Compilation for Android didnt work until I dont use ndk version as r5 like android-ndk-r5c. Is it so dependent on this.

Regards
symadept

No, you actually want NDK r7b now (or whatever the latest one is… they come out pretty often)

Hi Jules,

I would like to know what are the features supported by Android build??

Also want to know what are the features are yet to support.??

I need these information so that I can decide how to proceed further for my Android development.

Regards,
Godwin

Hi Jules,

Any updates on this???

It’s missing keyboard support, and a handful of other things, but is mostly there.

Thanks for the info…

By when can we expect it to work??

Expect keyboard support to work? When I get around to it.

I was able to get the Android JuceDemo running on a Nexus 7. Cool. I did have to change

-I "../../JuceLibraryCode"

to

-I "../../../JuceLibraryCode"

in Android.mk to get it to compile. I was bummed to find out keyboard entry wasn’t working. But I have to give my praise to everything Jules has done with Juce. I think it’s awesome. Thanks Jules.

Glad you like it! What you say about needing to change the path is really odd, because nobody else has had any problems with it, and if your current directory is the Builds/Android directory, then everything should be correct… You weren’t trying to build from inside Builds/Android/jni, were you?