tutorial single rxjava how for example curso androidhive android gradle android-gradle

android - how - rxjava single example



Problemas al usar rxjava-android (3)

Estoy intentando usar Rxjava en un proyecto que tengo con Gradle. No tengo ningún error de compilación, pero cuando ejecuto el proyecto, la aplicación falla.

12-01 14:40:41.553 1015-1015/? I/dalvikvm﹕ Could not find method rx.Subscription.unsubscribe, referenced from method com.flipper83.protohipster.view.feed.ui.HipsterListFragment.onPause 12-01 14:40:41.553 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve interface method 11579: Lrx/Subscription;.unsubscribe ()V 12-01 14:40:41.553 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0005 12-01 14:40:41.553 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observable;) 12-01 14:40:41.565 1015-1015/? I/dalvikvm﹕ Could not find method rx.concurrency.Schedulers.newThread, referenced from method com.flipper83.protohipster.view.feed.ui.HipsterListFragment.onResume 12-01 14:40:41.565 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve static method 11581: Lrx/concurrency/Schedulers;.newThread ()Lrx/Scheduler; 12-01 14:40:41.569 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0014 12-01 14:40:41.569 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment$1; interface 2027 ''Lrx/Observer;'' 12-01 14:40:41.569 1015-1015/? W/dalvikvm﹕ Link of class ''Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment$1;'' failed 12-01 14:40:41.569 1015-1015/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x148a at 0x1e in Lcom/flipper83/protohipster/view/feed/ui/HipsterListFragment;.onResume 12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observer;) 12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lrx/Observer;) 12-01 14:40:41.577 1015-1015/? I/dalvikvm﹕ Could not find method rx.Observer.onNext, referenced from method com.flipper83.protohipster.view.feed.model.FeedViewModel.notifyFeed 12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve interface method 11578: Lrx/Observer;.onNext (Ljava/lang/Object;)V 12-01 14:40:41.577 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x72 at 0x0028 12-01 14:40:41.577 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1; interface 2025 ''Lrx/Observable$OnSubscribeFunc;'' 12-01 14:40:41.577 1015-1015/? W/dalvikvm﹕ Link of class ''Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;'' failed 12-01 14:40:41.577 1015-1015/? E/dalvikvm﹕ Could not find class ''com.flipper83.protohipster.view.feed.model.FeedViewModel$1'', referenced from method com.flipper83.protohipster.view.feed.model.FeedViewModel.populateFeed 12-01 14:40:41.581 1015-1015/? W/dalvikvm﹕ VFY: unable to resolve new-instance 794 (Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;) in Lcom/flipper83/protohipster/view/feed/model/FeedViewModel; 12-01 14:40:41.581 1015-1015/? D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0000 12-01 14:40:41.581 1015-1015/? I/dalvikvm﹕ Failed resolving Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1; interface 2025 ''Lrx/Observable$OnSubscribeFunc;'' 12-01 14:40:41.581 1015-1015/? W/dalvikvm﹕ Link of class ''Lcom/flipper83/protohipster/view/feed/model/FeedViewModel$1;'' failed 12-01 14:40:41.581 1015-1015/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x145d at 0x02 in Lcom/flipper83/protohipster/view/feed/model/FeedViewModel;.populateFeed 12-01 14:40:41.585 1015-1015/? D/AndroidRuntime﹕ Shutting down VM 12-01 14:40:41.585 1015-1015/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa62ca288) 12-01 14:40:41.585 1015-1015/? E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.flipper83.protohipster.view.feed.model.FeedViewModel$1 at com.flipper83.protohipster.view.feed.model.FeedViewModel.populateFeed(FeedViewModel.java:43)

Creo que el problema proviene de Gradle. este es mi gradle build.xml.

buildscript { repositories { mavenCentral() } dependencies { classpath ''com.android.tools.build:gradle:0.6.+'' } } apply plugin: ''android'' repositories { mavenCentral() flatDir { dirs ''lib'' } } android { compileSdkVersion 19 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 14 targetSdkVersion 19 } sourceSets { main { assets.srcDirs = [''assets''] } } } dependencies { compile ''com.squareup.picasso:picasso:2+'' compile ''com.squareup.dagger:dagger-compiler:1.1.0'' compile ''com.squareup.dagger:dagger:1.1.0'' compile ''com.android.support:support-v4:18.0.+'' compile ''com.squareup.retrofit:retrofit:1.2.+'' compile ''com.netflix.rxjava:rxjava-android:0.14.+'' compile files(''lib/Parse-1.3.8.jar'') }

¿¿Alguna idea??


Basado en ReactiveX / RxAndroid : https://github.com/ReactiveX/RxAndroid

Es mejor usar las dependencias de Android y Java:

compile ''io.reactivex:rxandroid:1.0.1'' // Because RxAndroid releases are few and far between, it is recommended you also // explicitly depend on RxJava''s latest version for bug fixes and new features. compile ''io.reactivex:rxjava:1.0.14''


Sí, lo arreglé con:

compile ''com.netflix.rxjava:rxjava-core:0.+'' compile ''com.netflix.rxjava:rxjava-android:0.+'' compile ''com.squareup.retrofit:retrofit:1.5.0''

en mi build.gradle

Gracias


compile ''com.netflix.rxjava: rxjava-core: 0. +'' es la dependencia transitoria compilando ''com.netflix.rxjava: rxjava-android: 0. +'', y Gradle automatics resolvió esta dependencia y descargó