Configure Ice in android studio

**Hello,
1- I am trying to setup an android project using ice. Unfortunately I can not get it work. I get this error:
**
A problem was found with the configuration of task ':app:compileSlice' (type 'SliceTask').
- In plugin 'com.zeroc.gradle.ice-builder.slice' type 'com.zeroc.gradle.icebuilder.slice.SliceTask' property 'timestamps' is missing an input or output annotation.
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.Exception is:
org.gradle.internal.execution.WorkValidationException: A problem was found with the configuration of task ':app:compileSlice' (type 'SliceTask').- In plugin 'com.zeroc.gradle.ice-builder.slice' type 'com.zeroc.gradle.icebuilder.slice.SliceTask' property 'timestamps' is missing an input or output annotation.
Reason: A property without annotation isn't considered during up-to-date checking.
Possible solutions:
- Add an input or output annotation.
- Mark it as @Internal.
**2- In my build gradle file i add:
**
plugins { id 'com.android.application' id "com.zeroc.gradle.ice-builder.slice" version "1.4.7" } dependencies { implementation 'com.zeroc:ice:3.7.4' }
**
3- Here is my client implementation code
**
try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize()) { // #base = ic.stringToProxy("SimplePrinter:tcp -h 192.168.154.161 -p 10000") com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("SimplePrinter:default -p 10000"); // com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("SimplePrinter:tcp -h 192.168.65.161 -p 10000"); com.example.asr.Demo.PrinterPrx printer = com.example.asr.Demo.PrinterPrx.checkedCast(base); if(printer == null) { throw new Error("Invalid proxy"); } printer.printString("Hello World!"); }
Comments
This is for my middleware project at Avignon University and I am running out of time.
Thank your for your help.
You should update the builder version from 1.4.7 to 1.5.0
https://plugins.gradle.org/plugin/com.zeroc.gradle.ice-builder.slice
Thanks for your help, there is no more errors when compiling but I am trying to print a simple text message using a real android device and it is not working. Here is my implementation:
Could you please help me?
Thank you!!
The
checkedCast
operation does a remote produce call, if the device cannot contact the remote endpoint it could take some time to get a failure, You should add an invocation timeout to ensure this can report a failure in a timely manner, enabling network and protocol tracing is also helpful to debug issues like this:When debugging I find this: System.out: com.zeroc.Ice.SocketException
I/System.out: java.net.SocketException: Operation not permitted
Seems like your application manifest is missing the permissions to access the network, see https://github.com/zeroc-ice/ice-demos/blob/f362b7f0115134659e092a35b1eec7d503b234a9/java/android/hello/src/main/AndroidManifest.xml#L7-L11
Those are better documented in Android documentation.
Hello, it works now, but there is an other issue. The app closed unexpectedly when i launch it on my phone. I do not have any idea about this issue.
Here is my server configuration.
Android client:
At the end the printer is null when i using a real android device. By using an other client from an other computer it works fine.But it does not work when using my android real device.
does it work with android simulator? does the checked cast return a null proxy or throws an exception?
It returns a null proxy.
It does not work with emulator.
If
checkedCast
returns null it means the target object doesn't implement the given interface, this could happen if there is a mismatch between the client and server definitions.But in your example it reads
If this is not executed then
checkedCast
must be throwing an exception.Yes this line is executed. But printer always returns null.