We're Hiring!

Add Omero Java files to Android studio

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Add Omero Java files to Android studio

Postby Hang » Mon Jun 04, 2018 8:35 pm

Hi,

I'm trying to connect to my Omero server from my Android app. So, I downloads all the artifacts and added them as libraries. However, during compilation I'm getting error:
Code: Select all
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process Q:\Malaria\AndroidProject\Omero\app\libs\java-getopt.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing gnu/getopt/GetoptDemo.class
Error:com.android.dx.cf.iface.ParseException: class name (GetoptDemo) does not match path (gnu/getopt/GetoptDemo.class)
Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process Q:\Malaria\AndroidProject\Omero\app\libs\java-getopt.jar


I know this might be not in your expertise, but please let me know if you have some ideas.

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Add Omero Java files to Android studio

Postby rgozim » Tue Jun 05, 2018 9:54 am

Hi Hang!

Can you send me a link to a gist with your build.gradle file, or link me to your project if it's hosted on github/gitlab/bitbucket/etc. ?

Also, what is it you are trying to achieve on Android, there might be other ways to use OMERO from a mobile device that are useful to you?

Thanks,
Riad
User avatar
rgozim
Team Member
 
Posts: 25
Joined: Thu Jul 20, 2017 9:09 am

Re: Add Omero Java files to Android studio

Postby Hang » Tue Jun 05, 2018 7:26 pm

Hi,

I haven't added Omero to my project yet. So, I just started an empty project in Android studio right now, and trying to add Omero jar files as libraries.

And here is my gradle files:

Top-level build.gradle:
Code: Select all
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
   
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
       

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        mavenCentral()
        maven {
            name 'Unidata'
            url 'https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases'}
        maven {
            url 'http://artifacts.openmicroscopy.org/artifactory/maven/'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}



Module-level build.gradle
Code: Select all
apply plugin: 'com.android.application'

def javaOpts = [
        '-Dlog4j.configuration=log4j-cli.properties',
        '-Xmx512M'
]

version '5.4.4'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "gov.nih.nlm.omero"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    //testImplementation 'junit:junit:4.12'
    android { configurations.all { resolutionStrategy.force "junit:junit:4.8.2" } }
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile('ome:formats-gpl:5.7.3') {
    }
    compile('ome:formats-bsd:5.7.3') {
    }
    compile('org.springframework.ldap:spring-ldap:1.3.0.RELEASE') {
        exclude group: 'org.testng', module: 'testng'
    }
    compile('omero:blitz:5.4.4-ice36-b82') {
        exclude group: 'org.springframework.ldap', module: 'spring-ldap'
        exclude group: 'org.testng', module: 'testng'
        exclude group: 'hsqldb', module: 'hsqldb'
    }
    implementation files('libs/activation.jar')
    implementation files('libs/axis.jar')
    implementation files('libs/axis2-saaj.jar')
    implementation files('libs/axis-wsdl4j.jar')
    implementation files('libs/backport-util-concurrent.jar')
    implementation files('libs/blitz.jar')
    implementation files('libs/bufr.jar')
    implementation files('libs/common.jar')
    implementation files('libs/commons-beanutils.jar')
    implementation files('libs/commons-codec.jar')
    implementation files('libs/commons-collections.jar')
    implementation files('libs/commons-digester.jar')
    implementation files('libs/commons-discovery.jar')
    implementation files('libs/commons-io.jar')
    implementation files('libs/commons-lang.jar')
    implementation files('libs/commons-logging.jar')
    implementation files('libs/commons-validator.jar')
    implementation files('libs/ehcache-core.jar')
    implementation files('libs/filters.jar')
    implementation files('libs/formats-api.jar')
    implementation files('libs/formats-bsd.jar')
    implementation files('libs/formats-gpl.jar')
    implementation files('libs/glacier2.jar')
    implementation files('libs/grib.jar')
    implementation files('libs/guava.jar')
    implementation files('libs/httpclient.jar')
    implementation files('libs/httpcore.jar')
    implementation files('libs/httpmime.jar')
    implementation files('libs/ice.jar')
    implementation files('libs/icegrid.jar')
    implementation files('libs/icestorm.jar')
    implementation files('libs/ij.jar')
    implementation files('libs/ini4j.jar')
    implementation files('libs/insight.jar')
    implementation files('libs/java-getopt.jar')
    implementation files('libs/java-image-scaling.jar')
    implementation files('libs/jaxrpc-api.jar')
    implementation files('libs/jcommon.jar')
    implementation files('libs/jfreechart.jar')
    implementation files('libs/jhdf5.jar')
    implementation files('libs/JHotDraw.jar')
    implementation files('libs/jna.jar')
    implementation files('libs/joda-time.jar')
    implementation files('libs/json.jar')
    implementation files('libs/JWlz.jar')
    implementation files('libs/jxrlib-all.jar')
    implementation files('libs/kryo.jar')
    implementation files('libs/log4j.jar')
    implementation files('libs/logback-classic.jar')
    implementation files('libs/logback-core.jar')
    implementation files('libs/metadata-extractor.jar')
    implementation files('libs/metakit.jar')
    implementation files('libs/minlog.jar')
    implementation files('libs/model-psql.jar')
    implementation files('libs/native-lib-loader.jar')
    implementation files('libs/netcdf.jar')
    implementation files('libs/objenesis.jar')
    implementation files('libs/ome-codecs.jar')
    implementation files('libs/ome-common.jar')
    implementation files('libs/ome-jai.jar')
    implementation files('libs/ome-mdbtools.jar')
    implementation files('libs/ome-poi.jar')
    implementation files('libs/ome-xml.jar')
    implementation files('libs/perf4j.jar')
    implementation files('libs/platform.jar')
    implementation files('libs/poi.jar')
    implementation files('libs/serializer.jar')
    implementation files('libs/slf4j-api.jar')
    implementation files('libs/specification.jar')
    implementation files('libs/swing-worker.jar')
    implementation files('libs/swingx.jar')
    implementation files('libs/TableLayout.jar')
    implementation files('libs/turbojpeg.jar')
    implementation files('libs/xalan.jar')
    implementation files('libs/xercesImpl.jar')
    implementation files('libs/xmpcore.jar')
}


So, what I'm trying to accomplish is:

Upload the images that my users took with my Android app to the Omero server that I host.

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Add Omero Java files to Android studio

Postby rgozim » Thu Jun 07, 2018 8:29 am

Hi Hang,

Thanks for sending through the build.gradle

Currently omero:blitz has dependencies that are not compatible with the Android platform.

At the moment we currently have a PR opened against OMERO.web that will hopefully provide an API endpoint to allow for image imports, which I think might be the better solution for you. The PR is a work in progress but if you want to try it out, you will have to build OMERO.web, with the PR included, and deploy it on your host machine. Let us know what you decide to do and if you need any help with this!

Thanks,
Riad
User avatar
rgozim
Team Member
 
Posts: 25
Joined: Thu Jul 20, 2017 9:09 am

Re: Add Omero Java files to Android studio

Postby Hang » Thu Jun 07, 2018 5:06 pm

Hi Riad,

Thanks for the suggestion. But let me make sure I understand how this would work. So, my Android app will connect to OMERO.web via some API?

If so, this sounds indirect than establish a connection directly to the server itself. After all, OMERO.web is just another client to the server. Connecting my Android app -> OMERO.web -> OMERO.server seems redundant.

I would prefer to work with the Java API. It seems like the right way to go if the dependency issue can be solved. I'm open to both solutions. But please help me understand the concept of the first one a little better then I can make a decision.

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Add Omero Java files to Android studio

Postby rgozim » Thu Jun 07, 2018 9:58 pm

Hi Hang,

That is correct. OMERO.web, although a client to OMERO.server, is itself a server "application" (in the strictest sense). OMERO.web would be deployed on your host machine, alongside OMERO.server, and provides a JSON API which is useful for client applications, such as an Android or iOS app.

Although conceptually it may seem strange, it is a common way to develop mobile applications. Mobile applications typically communicate with a sever via HTTP using JSON as a serialisation language.

omero-client-server.jpg
omero-client-server.jpg (15.11 KiB) Viewed 2903 times


If it helps, I have a small Android application that performs a login using the OMERO.web API that I can share with you?

Thanks,
Riad
User avatar
rgozim
Team Member
 
Posts: 25
Joined: Thu Jul 20, 2017 9:09 am

Re: Add Omero Java files to Android studio

Postby Hang » Fri Jun 08, 2018 2:36 pm

Thanks for the explanation. Now I get it.

And of course!! I would love to have that example!

Also, how do I build OMERO.web with the included PR?

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Add Omero Java files to Android studio

Postby wmoore » Mon Jun 11, 2018 9:20 am

I should warn you that the OMERO.web PR that adds support for import is really at the prototype stage just now (it's now closed to avoid confusion - apologies for that).

We're just trying to evaluate what needs doing to support Import from the web, and haven't tried POSTing to any web URL except from the browser (haven't documented the end-point etc).

The blockers for that PR are currently server-side: Some limitations in functionality since we don't have access to BioFormats to be able to know how to organise multiple files into separate "filesets" / images.
Also some errors which we've not yet investigated.

We probably need to discuss this within the team to advise you of the best way forward...

Regards,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Add Omero Java files to Android studio

Postby Hang » Thu Jun 28, 2018 4:48 pm

Hi there,

Any updates regarding this issue?

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Add Omero Java files to Android studio

Postby jmoore » Fri Jun 29, 2018 2:03 pm

Hi Hang,

Riad is away, but when he returns he'll send you the example he was talking about. Assuming you want to pursue the web API path, you'll likely be limited to the currently existing API or you'll need to add the API endpoints you're looking for locally. If you want to build Will's PR, you'll need to fetch it locally and follow https://docs.openmicroscopy.org/omero/5.4.6/developers/installation.html. Note, though, that the API there is still in flux.

Good luck and keep us posted!
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Next

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests