Home Comments

Configure Ice in android studio

amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

**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:

    1. Add an input or output annotation.
    2. 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

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    This is for my middleware project at Avignon University and I am running out of time.
    Thank your for your help.

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    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

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    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:

     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 10.120.25.162 -p 10000");
    
                Log.d("Ice","This code is executed");
    
                com.example.asr.Demo.PrinterPrx printer = com.example.asr.Demo.PrinterPrx.checkedCast(base);
    
               Log.d("Ice","This line is not executed");
    
                if(printer == null)
                {
                    Log.d("Adapter","2");
    
                    throw new Error("Invalid proxy");
                }
    
                Log.d("Ice","This part is not excuted");
    
                printer.printString("Hello World!");
    
                Log.d("Adapter","Print String works");
    
            }catch(Exception e){
               Log.d("Exeption","ice failed");
    
               System.out.println(e);
           }
    

    Could you please help me?

    Thank you!!

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    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:

    InitializationData initData = new InitializationData();
    initData.properties = Util.createProperties();
    initData.properties.setProperty("Ice.Trace.Network", "3");
    initData.properties.setProperty("Ice.Trace.Protocol", "1");
    
     try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(initData))
     {
    
         ...
    
        com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("SimplePrinter:tcp -h 10.120.25.162 -p 10000");
        base.ice_invocationTimeout(2000); // 2 seconds
        ...
     }
    
  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    When debugging I find this: System.out: com.zeroc.Ice.SocketException

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    I/System.out: java.net.SocketException: Operation not permitted

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    edited April 1

    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.

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    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.

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    Here is my server configuration.

    try:
        ic = Ice.initialize(sys.argv)
        adapter = ic.createObjectAdapterWithEndpoints(
        "SimplePrinterAdapter", "tcp  -p 10000")
        object = PrinterI()
        adapter.add(object, ic.stringToIdentity("SimplePrinter"))
        adapter.activate()
        ic.waitForShutdown()
    except:
        traceback.print_exc()
        status = 1
    
    if ic:
        # Clean up
        try:
            ic.destroy()
        except:
            traceback.print_exc()
            status = 1
    

    Android client:

     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");
                Log.d("Ice","This code is executed");
    
                com.zeroc.Ice.ObjectPrx base = communicator.stringToProxy("SimplePrinter:tcp -h 192.168.248.161 -p 10000");
                Log.d("Ice","This code is executed");
    
                com.example.asr.Demo.PrinterPrx printer = com.example.asr.Demo.PrinterPrx.checkedCast(base);
                Log.d("Ice","This line is not executed");
    
                if(printer == null)
                {
                    Log.d("Adapter","2");
    
                    throw new Error("Invalid proxy");
                }
                Log.d("Ice","This part is not executed");
    
                printer.printString("Hello World!");
                Log.d("Adapter","Print String works");
    
            }catch(Exception e){
                Log.d("Exception","ice failed");
    
                System.out.println(e.getMessage());
            }
    

    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.

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    does it work with android simulator? does the checked cast return a null proxy or throws an exception?

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    It returns a null proxy.

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    It does not work with emulator.

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    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

    Log.d("Ice","This line is not executed");
    

    If this is not executed then checkedCast must be throwing an exception.

  • amosamos Member AmosOrganization: CERIProject: My project is about building a distributed application on which a user can stream video from a streaming server by using ASR and TAL.

    Yes this line is executed. But printer always returns null.

Sign In or Register to comment.