Native interface target platform selection?

116 views
Skip to first unread message

Cristian Ionitoiu

unread,
Jun 30, 2014, 5:10:52 AM6/30/14
to codenameone...@googlegroups.com
Hi there,

I'm trying to run a test for the native interface feature of CN1. I have created a custom native interface extension, generated the stubs, and activated as supported only the ios generated stub and rebuilt the project.  My extension looks like this

public interface S3 extends NativeInterface {
    public String concatenate(String val1, String val2);
}

Then, In the code I used it the following manner:

S3 s3obj = (S3)NativeLookup.create(S3.class);
String test = s3obj.concatenate("first", "second");


The ios generated stub is below

@interface de_infobest_mixme_cloud_S3Impl : NSObject {
}

-(NSString*)concatenate:(NSString*)param param1:(NSString*)param1;
-(BOOL)isSupported;
@end


And the other stubs are called S3Impl classes (for Android, javase and j2me).  Problem is that despite the fact that the only supported platform is iOS (corresponding method returns YES, all the other return false), CN1 does not select iOS native implementation for s3obj creation. s3obj  is created using javase native implementation. If javase native implementation is activated (suportted) as well then test value is fine, but if only iOS is supported then test object has value null. In debug mode one could see that s3obj is of type S3Impl (and not of ios generated type). Is the selection of the native platform related to the setup of iOS properties in project description? How would one enforce selection of iOS platform for native interface implementation? Thanks and best regards.

Shai Almog

unread,
Jun 30, 2014, 10:21:28 AM6/30/14
to codenameone...@googlegroups.com
Hi,
in the simulator you will always get the JavaSE version. We can't compile Objective-C/C#/Dalvik on your machine.
When sending a build to the server the native code to the various platforms will be used.

Cristian Ionitoiu

unread,
Jul 1, 2014, 1:13:08 PM7/1/14
to codenameone...@googlegroups.com

Hi Shai,

Thanks a lot for your answer. I have modified my code so only the iOS native version is supported and sent the build to the CN1 server. The build failed with java.lang.ClassNotFoundException: S3Impl. So it seems that CN! still wants the javaSE implementation to be available. To have a full picture, please note that I still have not received my iOS developer credentials from Apple, so I did not fill any information related to that in the project - so I got a warning from CN1 server saying that it is going to use CN Apple credentials on a demo basis. Would this situation (that the build is not hooking in iOS implementation of native interface) be related to missing Apple credentials? Thanks and best regards,

Cristian

Steve Hannah

unread,
Jul 1, 2014, 1:19:20 PM7/1/14
to codenameone...@googlegroups.com
If you're using your native interface on the first form of your app, then the build server will run the JavaSE version to take screenshots.  Make sure you are using the isSupported() mechanism of the native interface before using any functionality in your code to make sure that your app doesn't try to do anything that it's not supposed to.




--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/6f580b56-a3d0-49b4-85a5-a563ad1c7408%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Web Lite Solutions Corp.

Shai Almog

unread,
Jul 2, 2014, 1:33:36 AM7/2/14
to codenameone...@googlegroups.com
Steve is correct, you need to check for null which the native lookup method can return.
To understand what is happening in the first form and why that's important read this: http://www.codenameone.com/3/post/2014/03/the-7-screenshots-of-ios.html

Cristian Ionitoiu

unread,
Jul 2, 2014, 3:13:44 AM7/2/14
to codenameone...@googlegroups.com
Hi Shai and Steve,

Yes I use the native interface in the first form of the app. I read the link that Shai recommended, and I think I understand the problem. But, it is still not clear to me how to use native interface for iOS in CN1 so that it actually works. For me the NPE is not an issue, and yes I could use issupported to avoid it, but how do I actually use the native interface object so that it does what it is supposed to do? Where and how to place the construction of the native interface object so it is correctly populated with the iOS implementation? Any hint in this direction will be greatly appreciated. Thanks,

Cristian 

Shai Almog

unread,
Jul 2, 2014, 10:19:21 AM7/2/14
to codenameone...@googlegroups.com
Hi,
did you look at the native demo sample and the ZXing sample?
Just create the object with the native lookup. Then assuming its not null and isSupported() returns true just invoke the appropriate methods on it.

infobest...@gmail.com

unread,
Jul 3, 2014, 3:25:25 AM7/3/14
to codenameone...@googlegroups.com
Hi Shai,

I have studied carefully the ZXing demo and your video about Native Interface
http://www.codenameone.com/how-do-i---access-native-device-functionality-invoke-native-interfaces.html

I declare an interface S3 that inherits from NativeInterface


public interface S3 extends NativeInterface {
    public String concatenate(String val1, String val2);
}

Then, I generated the stubs, put some code in iOS implementation and made isSupported return YES. For all the other implementations isSupported() return false.  And I use it as I seen in both the demo and your video,

final S3 s3obj = (S3)NativeLookup.create(S3.class); //line 74
String test = null;
if (s3obj != null && s3obj.isSupported()) {

      test = s3obj.concatenate("first", "second");
}

I send the build to server as iOS Debug Build and it fails with
 
java.lang.ClassNotFoundException: [package_path].S3Impl
at com.codename1.system.NativeLookup.create(NativeLookup.java:55)
at [package_path].showMainUI(Main.java:74)

While the ZXing demo builds correctly. What is wrong now? Why is picking up again S3Impl (of javaSE?)? Thanks

Cristian

Shai Almog

unread,
Jul 3, 2014, 10:35:44 AM7/3/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi,
your build fails with a different error but you are fixating on that error which is irrelevant. I'm guessing you have a certificate issue right below but without the full log this is just a guess. Try
http://www.codenameone.com/3/post/2013/10/ios-code-signing-fail-checklist.html

infobest...@gmail.com

unread,
Jul 4, 2014, 2:28:58 AM7/4/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi Shai,

 So you  are saying that the current error is a side-effect deriving from a iOS certificate issue. As I mentioned in the first post, we are still waiting for our DUNS number, so we do not have iOS certificates yet. But when I send the build to your CN1 server I get a warning windows that tells (if I understand it well) that since there are no certificates, CN1 server will use some provisional certificates to sign the build. Is this correct?
On the other hand, when I send the ZXing demo build to CN1 server I get the same warning, and there are no problems, ZXing is built without problems. I checked the iOS section of project properties both for my application and ZXing demo and both have only APP ID field filled-in with some CN1 predefined value. Native Interface code usage is the same for my application and ZXing demo, so I don;t understand why ZXing demo builds and mine does not.
Also, I checked the error log from my build and I see no other errors beside the NoClassFoundException. Could you please explain, I'm a bit confused. Do you want me to attach anything to this ticket? I will do it ....
Thanks a lot,

Cristian

Shai Almog

unread,
Jul 4, 2014, 12:21:09 PM7/4/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi,
I'm saying that you should attach the full error you are getting because its hard to tell from this amount of information.

infobest...@gmail.com

unread,
Jul 7, 2014, 3:33:45 AM7/7/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi Shai,

I cannot send you the logs because the free quota of cloud objects has finished. Is it possible to switch the build to another free account on server? I tried to do that but I cannot find any options. Thanks and best regards,

Cristian

Shai Almog

unread,
Jul 7, 2014, 10:24:56 AM7/7/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi,
cloud object != build credits.

Its prohibited by our EULA to switch accounts for the purpose of circumventing our quotas and we do ban people who abuse that.

infobest...@gmail.com

unread,
Jul 8, 2014, 10:06:36 AM7/8/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi Shai,

Ooops, sorry I did not know that. Well in this case  I'm kind of blocked. I mean it is still not clear to me if I can use Native Interfaces and I can't build the project anymore. I'm afraid that I might not have enough to convince my company to further back codename one track for our mobile development. It seems to be quite complicated and limited in resources. Best regards,

Cristian

Shai Almog

unread,
Jul 8, 2014, 10:41:56 AM7/8/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi,
sorry to hear that. We have a pro trial account which you can take for 1USD which has no restrictions.
The problem isn't related to native interfaces, its related to you running out of build credits in the free account which are very limited for iOS builds to reduce server overload.

infobest...@gmail.com

unread,
Jul 9, 2014, 4:48:42 AM7/9/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi Shai,

I noticed that I'm inclined to take that subscription but what happens when the 14 days expire? Do you automatically charge the Paypal account with 79 dollars? Do I have to cancel the subscription explicitly during this period of 14 days?
Also, I noticed that there are some logs left on server from last run before my credits expired. Please find it attached as you initially requested.
Thanks,

Cristian
cn1_log.txt

Shai Almog

unread,
Jul 9, 2014, 9:58:49 AM7/9/14
to codenameone...@googlegroups.com, infobest...@gmail.com
Hi,
you have to cancel explicitly we do charge.
We do have a money back guarantee so if you forget to cancel drop us a line, however its painful to cancel if the charge makes it to our books so we appreciate it if you remember to do it yourself.

Please notice that if you do take that trial then do choose to purchase the product thru your employer, you aren't supposed to take the trial again.

About the log if you scroll to the end you will see there is a compilation error in your native code, hard to tell what is the trigger for it without looking at the code though but it seems that line 6 has an error:
/dist/build/MixMe.build/Release-iphoneos/MixMe.build/Objects-normal/armv7/de_infobest_mixme_cloud_S3Impl.o
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build1512326948440470552xxx/dist/../build/xcode/src/app/de_infobest_mixme_cloud_S3Impl.m: In function '-[de_infobest_mixme_cloud_S3Impl tenate:param1:]':
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build1512326948440470552xxx/dist/../build/xcode/src/app/de_infobest_mixme_cloud_S3Impl.m:6: error: 'testlib' undeclared (first use in this function)
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build1512326948440470552xxx/dist/../build/xcode/src/app/de_infobest_mixme_cloud_S3Impl.m:6: error: (Each undeclared identifier is reported only once
/var/folders/p_/xlvwhg4101z8r81_nl13cds80000gn/T/build1512326948440470552xxx/dist/../build/xcode/src/app/de_infobest_mixme_cloud_S3Impl.m:6: error: for each function it appears in.)


Reply all
Reply to author
Forward
0 new messages