Can't build Android native extension - undefined base

J Jon Tara 2 years 11 months ago
2 3 0

I've written a native extension and implemented for iOS. Now want to implement for Android.

Right now, just trying to implement and test calcSumm(), but having no luck building.

All I have changed from the generated code is to remove getPlatformString() and joinStrings() demo functions (keeping calcSumm()).

I get:

Compiling java sources: ["/Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/RhodesSRC_build.files"]
PWD: /Users/jon/.rvm/gems/ruby-2.2.2@rhodes-5.0.30-sp3-57e9d466-watusi/gems/rhodes-5.0.30
CMD: /Library/Java/Home/bin/javac -g -d /Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/Rhodes -source 1.6 -target 1.6 -nowarn -encoding latin1 -classpath /Users/jon/sdk/android/sdk/platforms/android-22/android.jar:/Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/Rhodes:/Users/jon/sdk/android/sdk/extras/android/support/v4/android-support-v4.jar @/Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/RhodesSRC_build.files
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

PWD: /Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/Rhodes
CMD: /Library/Java/Home/bin/jar cf /Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/librhodes/Rhodes.jar .
-$TIME$- message [ build:android:rhodes FINISH ] time is { 2015-04-26T20:56:42Z } milliseconds from start (7139)
-$TIME$- message [ build:android:extensions_java START ] time is { 2015-04-26T20:56:42Z } milliseconds from start (7140)
Compile extensions java code
/Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/extensions/coreapi/coreapi.jar is uptodate: true
Compiling java sources: ["/var/folders/qs/mry441454mq56w00y5f59c200000gn/T/BonjourBrowserSRC_build20150426-39991-foco3u"]
PWD: /Users/jon/.rvm/gems/ruby-2.2.2@rhodes-5.0.30-sp3-57e9d466-watusi/gems/rhodes-5.0.30
CMD: /Library/Java/Home/bin/javac -g -d /Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/BonjourBrowser -source 1.6 -target 1.6 -nowarn -encoding latin1 -classpath /Users/jon/sdk/android/sdk/platforms/android-22/android.jar:/Users/jon/sdk/android/sdk/extras/android/support/v4/android-support-v4.jar:/Users/jon/workspace/Sargent/build/android/singer/development/bin/tmp/Rhodes:/Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/extensions/coreapi/android-support-v4.jar:/Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/extensions/coreapi/coreapi.jar:/Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/librhodes/Rhodes.jar:/Users/jon/workspace/Sargent/build/android/singer/development/bin/target/android/release/extensions/coreapi/coreapi.jar @/var/folders/qs/mry441454mq56w00y5f59c200000gn/T/BonjourBrowserSRC_build20150426-39991-foco3u
/Users/jon/workspace/Sargent/build/android/singer/development/extensions/BonjourBrowser/ext/platform/android/src/com/rho/bonjourbrowser/BonjourBrowser.java:10: cannot find symbol
symbol  : constructor BonjourBrowserBase()
location: class com.rho.bonjourbrowser.BonjourBrowserBase
  public BonjourBrowser(String id) {
                                   ^
1 error

rake aborted!
Error compiling java code

BonjourBrowser.java

package com.rho.bonjourbrowser;

import java.util.Map;

import com.rhomobile.rhodes.api.IMethodResult;
import com.rhomobile.rhodes.api.MethodResult;

public class BonjourBrowser extends BonjourBrowserBase implements IBonjourBrowser {

    public BonjourBrowser(String id) {
        super(id);
    }

    @Override
    public void calcSumm(int a, int b, IMethodResult result) {
          result.set(a+b);
    }

}

ext/platform/android/ext_java.files

ext/platform/android/generated/src/com/rho/bonjourbrowser/BonjourBrowserBase.java
ext/platform/android/generated/src/com/rho/bonjourbrowser/BonjourBrowserFactorySingleton.java
ext/platform/android/generated/src/com/rho/bonjourbrowser/BonjourBrowserSingletonBase.java
ext/platform/android/generated/src/com/rho/bonjourbrowser/IBonjourBrowser.java
ext/platform/android/generated/src/com/rho/bonjourbrowser/IBonjourBrowserFactory.java
ext/platform/android/generated/src/com/rho/bonjourbrowser/IBonjourBrowserSingleton.java
ext/platform/android/src/com/rho/bonjourbrowser/BonjourBrowser.java
ext/platform/android/src/com/rho/bonjourbrowser/BonjourBrowserFactory.java
ext/platform/android/src/com/rho/bonjourbrowser/BonjourBrowserSingleton.java

I'm afraid I know absolutely nothing about Android development. But I'd have expected the extension to build with the default code.

I guess I am supposed to remove/comment super(id), but that doesn't make a difference.

What am I missing?

Please register or login to post a reply

3 Replies

V Vedsatx Saddvv

Yes, we did cover that at AppForum 2014. Links to all the presentations are on the right-hand side of the page. There are two on "Using Native Extensions" including one with sample code.

J Jon Tara

Thanks for the link.

Unfortunately, those two sessions were both about creating WM extensions. I'm trying to create an Android extension.

It's humbling to be stumbling-around on a platform you are unfamiliar with. I can write iOS extensions till the cows come home! But I'm pretty lost on Android.

It doesn't help that I've written a pretty fully-featured extension for iOS. The examples I've seen are all rather basic. I'm trying to create a "poster child" extension with all of the bells and whistles.That is, it has:

- properties
- constants
- a method that accepts (hopefully, an optional...) properties hash that get merged with existing properties
- a method with an optional callback (the same as the one above)
- asynchronous callbacks
- factory, with a default instance

What I am finding, I am afraid, is that not all the bells and whistles work on every platform.

I've had to go poking-around through the Rhodes source code for example code, and then figure out which APIs follow best practices, and which ones kludge it up in one way or another. I only find bits and pieces in different APIs, since no one API seems to fully embrace the 4.x+ API principles. Many of the Rhodes APIs collapse the implementation and base code together, which, of course, is a sensible optimization for core APIs, but makes it difficult to relate that code to how one might do it in a generated extension.

I seem to be having trouble here with an optional callback. I'm not really sure how to handle that. In my iOS extension, in order to have an optional callback as the last parameter, I had to make the first parameter (an properties hash) mandatory. I haven't yet worked-out the code to allow the first parameter to be omitted. No big deal, for now I pass {} if I don't want to set any properties.

It works fine in iOS. But for Android, my implementation of the method that has the optional callback ("browse") isn't even being called. The C ruby adapter code is giving an error message as shown above:

I/APP    ( 1812): E 04/27/2015 17:58:27:635 00000742  BonjourBrowserRUBY| Error setting callback ^^^ 

And then never calls my implementation code. What is strange is that I DID supply a callback! I think that in the case of Android that the generated code assumes that the optional callback will be in the first parameter. maybe android C adapter code does some checking that iOS C adapter code does not. I will try making it a mandatory callback.

My other methods (calcSumm() example and stopBrowsing() ) are being called. Finger seems to point at optional callback.

Any help appreciated. I'll be open-sourcing this once I complete the Android implementation. (I have no interest in WM, but if somebody else wants to implement a bonjour browser for WM,..) That gives the community two useful things:

- A Bonjour Browser extension
- An example extension that exercises all of the features of Factory-based extensions

I've been working on this for now inside an app I am working on. But if anyone is interested in helping, I think the easiest thing would be for me to make a minimal sample app with the extension built-in.

J Jon Tara

I generated a new app, and then generated a new extension, with same name as mine (was concerned might be issues with upper/lower case extension name, so used same name.

Baffled because it builds just fine. I can't find any difference between the newly-generated API and mine, save for my iOS implementation, and the couple of generated demo methods that I removed.

The file lists are identical.

ext.yml is identical.

Can't seem to find what is different. I guess I will have to move my extension out of the project to a safe place and start over (generate a new extension), then move my XML and my iOS code back in.

Anybody else encounter this?

Also, not sure now why it is that I should remove super(id). I didn't my my test app, and calcSumm() works. Not sure what that is supposed to accomplish, and the documentation doesn't give any reason.

CONTACT
Can’t find what you’re looking for?