Retrofit + RxJava compatibility

Hello guys,

I am loving multi OS, awesome work!

I am trying to use Retrofit+RxJava as http client in iOS, so I can keep compatibility with other android app, and dex2oat task always fails.

Execution failed for task ‘:digicash_ios_project:moeMainDebugX86Dex2Oat’.

Process ‘command ‘/Applications/Intel/multi_os_engine/tools/dex2oat’’ finished with non-zero exit value 134

I am not sure how to proceed or debug this, I am still too fresh with multi OS, is this library incompatibility? My libs are JAVA-only (I believe), heres my gradle dependency:

compile 'com.squareup.retrofit:retrofit:1.9.0’
compile 'com.netflix.rxjava:rxjava-core:0.20.6’

Any tips? :slight_smile: thank you

Dear TMSantos,

Could you please attach the complete error message? Also if you have a sharable project where we can replicate the issue, that would be appreciated!

Dear liliomk,

Thank you for your fast reply, here is full error log:

Build started (1.0.702)
Incremental java compilation is an incubating feature.
WARNING [Project: :UILayer] To shrink resources you must also enable ProGuard
WARNING [Project: :UILayer] To shrink resources you must also enable ProGuard
WARNING [Project: :UILayer] To shrink resources you must also enable ProGuard
WARNING [Project: :UILayer] To shrink resources you must also enable ProGuard
WARNING [Project: :UILayer] To shrink resources you must also enable ProGuard
:digicash_ios_project:compileJava UP-TO-DATE
:digicash_ios_project:processResources UP-TO-DATE
:digicash_ios_project:classes UP-TO-DATE
:digicash_ios_project:moeMainProGuard UP-TO-DATE
:digicash_ios_project:moeMainRetrolambda
:digicash_ios_project:moeMainDebugDex UP-TO-DATE

###########

ERROR LOG

###########

dex2oat I 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/dex2oat/dex2oat.cc:2220] /Applications/Intel/multi_os_engine/tools/dex2oat --instruction-set=x86 --base=0x40000000 --compiler-backend=Quick --generate-debug-info --image=/Users/tiago/Digicash/AndroidApp/PaymentApplication/digicash_ios_project/build/moe/main/Debug/x86/image.art --image-classes=/Applications/Intel/multi_os_engine/tools/preloaded-classes --oat-file=/Users/tiago/Digicash/AndroidApp/PaymentApplication/digicash_ios_project/build/moe/main/Debug/x86/application.oat --dex-file=/Users/tiago/Digicash/AndroidApp/PaymentApplication/digicash_ios_project/build/moe/main/Debug/classes.jar:/Applications/Intel/multi_os_engine/sdk/intel-moe-core.dex:/Applications/Intel/multi_os_engine/sdk/intel-moe-ios-retro.jar
dex2oat I 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/runtime/parsed_options.cc:449] setting boot class path to /Users/tiago/Digicash/AndroidApp/PaymentApplication/digicash_ios_project/build/moe/main/Debug/classes.jar:/Applications/Intel/multi_os_engine/sdk/intel-moe-core.dex:/Applications/Intel/multi_os_engine/sdk/intel-moe-ios-retro.jar
dex2oat W 8292 182196 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/dex/verification_results.cc:61] Method processed more than once: void android.icu.text.NumberFormat.()
dex2oat W 8292 182196 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String java.lang.AbstractStringBuilder.substring(int)
dex2oat W 8292 182196 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String com.android.org.bouncycastle.util.Strings.toLowerCase(java.lang.String)
dex2oat W 8292 182196 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/dex/verification_results.cc:61] Method processed more than once: java.lang.String java.lang.IntegralToString.stringOf(char[])
dex2oat I 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/runtime/gc/heap.cc:2713] Explicit concurrent mark sweep GC freed 22546(5MB) AllocSpace objects, 0(0B) LOS objects, 37% free, 6MB/10MB, paused 17us total 9.285ms
dex2oat F 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/oat_writer.cc:645]Unexpected failure to resolve a method: void retrofit.client.ApacheClient$GenericEntityHttpRequest.(retrofit.client.Request)dex2oat F 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/oat_writer.cc:650] java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
dex2oat F 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/compiler/oat_writer.cc:650] (Throwable with empty stack trace)
dex2oat F 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/runtime/runtime.cc:448]Runtime aborting…
Aborting thread:
“main” prio=5 tid=1 Runnable (still starting up)
| group="" sCount=0 dsCount=0 obj=0x0 self=0x7fdf93002c00
| sysTid=182180 nice=-1 cgrp=default sched=1/31 handle=0x7fff7c5c2000
| state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
| stack=0x7fff58f9a000-0x7fff58fa2000 stackSize=8MB
| held mutexes= “abort lock” “mutator lock”(shared held)
(no managed stack frames)
Pending exception java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
(Throwable with empty stack trace)Dumping all threads without appropriate locks held: thread list lock
All threads:
DALVIK THREADS (1):
“main” prio=5 tid=1 Runnable (still starting up)
| group="" sCount=0 dsCount=0 obj=0x0 self=0x7fdf93002c00
| sysTid=182180 nice=-1 cgrp=default sched=1/31 handle=0x7fff7c5c2000
| state=? schedstat=( 0 0 0 ) utm=0 stm=0 core=0 HZ=100
| stack=0x7fff58f9a000-0x7fff58fa2000 stackSize=8MB
| held mutexes= “abort lock” “mutator lock”(shared held)
(no managed stack frames)

dex2oat W 8292 182180 /teamcity/workdir/moe_repo_build/moe_repo/art/runtime/barrier.cc:96] Attempted to destroy barrier with non zero count -1
:digicash_ios_project:moeMainDebugX86Dex2Oat FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:digicash_ios_project:moeMainDebugX86Dex2Oat’.

Process ‘command ‘/Applications/Intel/multi_os_engine/tools/dex2oat’’ finished with non-zero exit value 134

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1 mins 46.768 secs
BUILD FINISHED WITH ERROR: see above

I cannot provide any code now, ill setup a github example with it asap if this log doesn’t help.

Looks like the problem comes from Retrofit library.

Thank you :slight_smile:

Dear TMSantos,

There are two missing dependencies::

compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.2.0'

Also ProGuard will trim out some classes which retrofit requires. Please add a proguard.append.cfg file to your MOE module with the following contents:

-keep class retrofit.http.** { *; }

Hey liliomk,

Sorry for late response.

The project compiles with that dependencies you mentioned, do you mind explaining me how did you find that these two were missing? So perhaps I can find it next time :slight_smile: I thought everything was included in initial retrofit compile.

It works great, amazing!

Other question:
Ex:

RestClient.instance.getRandomTrivia()
.subscribe(new Observer() {
@Override
public void onCompleted() {

                }
                @Override
                public void onError(Throwable e) {
                }
                @Override
                public void onNext(TriviaResponse triviaResponse) {
                        statusText.setText(text);
                }
            });

How do I set text to an UI label inside an observer callback?

 statusText.setText(text); --> not working, I assume it is not being called in UI thread or something?

Thanks

Dear TMSantos,

Explanation would not be so simple, but we already have plans for improving error messages for situations like this. However when you see this message Pending exception java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available it mostly comes down to searching for missing classes, most likely from dependencies (sometimes from dependencies marked as optional).
This messages gives a good starting point: Unexpected failure to resolve a method: void retrofit.client.ApacheClient$GenericEntityHttpRequest.(retrofit.client.Request). You need to dig into the source code of this method and look for dependencies your IDE cannot correctly resolve, those are the dependencies you are most likely missing.

Regarding ReactiveX, we have a port and a sample project here.

Dear liliomk,

Nice,everything is working great, RxJava and Retrofit.
MultiOS is really amazing.

Thanks for your help!