2017-12-19 18 views
0

Proguard로 빌드하면 Observable에서 'Observable에서 참조 된 클래스를 찾을 수 없습니다.'라는 경고가 나타납니다.Proguard 경고 : Observable에서 참조 된 클래스를 찾을 수 없습니다.

하지만 Observable을 여러 곳에서 사용하고 있지만 경고 코드는 아래 코드에만 있습니다.

viewModel.data.observe(this, Observer<Boolean> { 

    // Warning: can't find referenced class 
    Single.fromCallable { 
     updateSomething() 
    } 
    .delay(2, TimeUnit.SECONDS) 
    .subscribe({}, { 
     it.printStackTrace() 
    }) 
}) 

아마도 ViewModel과 관련이 있습니까? 'Single.fromCallable ...'블록을 주석 처리하면 경고없이 빌드 할 수 있습니다.

이 문제를 어떻게 해결할 수 있습니까?

[편집] 내 현재 proguard-rules.pro

############################################################ 
## Retrofit2 
############################################################ 
-dontwarn retrofit2.** 
-keep class retrofit2.** { *; } 
-keepattributes Signature 
-keepattributes Exceptions 
-dontwarn javax.annotation.** 
-keepclasseswithmembers class * { 
    @retrofit2.http.* <methods>; 
} 

############################################################ 
## okhttp3 
############################################################ 
-dontwarn okhttp3.** 
-dontwarn okio.** 

############################################################ 
## For picasso 
############################################################ 
-dontwarn com.squareup.okhttp.** 

############################################################ 
## For com.caverock:androidsvg 
############################################################ 
-dontwarn com.caverock.androidsvg.** 

############################################################ 
## For Gson 
############################################################ 
-keep class com.google.** {*;} 
-keep interface com.google.** {*;} 

# For using GSON @Expose annotation 
-keepattributes *Annotation* 

# Gson specific classes 
-dontwarn sun.misc.** 
#-keep class com.google.gson.stream.** { *; } 

# Application classes that will be serialized/deserialized over Gson 
-keep class com.google.gson.examples.android.model.** { *; } 

# Prevent proguard from stripping interface information from TypeAdapterFactory, 
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) 
-keep class * implements com.google.gson.TypeAdapterFactory 
-keep class * implements com.google.gson.JsonSerializer 
-keep class * implements com.google.gson.JsonDeserializer 

############################################################ 
## For NonSwipeableViewPager 
############################################################ 
-keep class android.support.v4.view.ViewPager { *; } 

############################################################ 
## For RxJava 
############################################################ 
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 
    long producerIndex; 
    long consumerIndex; 
} 

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 
    rx.internal.util.atomic.LinkedQueueNode producerNode; 
} 

-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { 
    rx.internal.util.atomic.LinkedQueueNode consumerNode; 
} 

-dontnote rx.internal.util.PlatformDependent 

오류 메시지,

경고 : com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 1 $ 1 $ 3 : 참조 찾을 수없는 클래스 com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 경고 1 : com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 1 $ 1 $ 3 : 는 참조 찾을 수없는 클래스 com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 1 경고 : com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 1 $ 1 $ 4 : 할 수 없습니다 참조 된 클래스를 찾으십시오 com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ 1 경고 : com.test/view.list.PhotoListFragment $ observeUpdates는 $ 2 $ 1 $ 1 $ 4 : 수는 )는 (참조 클래스 com.test/view.list.PhotoListFragment $ observeUpdates $ 2 $ (1)

observeUpdates을 찾을 방법은 포함되지 위의 코드.

답변

0

당신은 당신의 Proguard와이 라인을 유지하는 시도 할 수 있습니다 :

-keepnames class rx.Single 



#rxjava 
-keep class rx.schedulers.Schedulers { 
    public static <methods>; 
} 
-keep class rx.schedulers.ImmediateScheduler { 
    public <methods>; 
} 
-keep class rx.schedulers.TestScheduler { 
    public <methods>; 
} 
-keep class rx.schedulers.Schedulers { 
    public static ** test(); 
} 

-keep class rx.internal.util.unsafe.** { 
    *; 
} 
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 
    long producerIndex; 
    long consumerIndex; 
} 
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 
    long producerNode; 
    long consumerNode; 
} 
+0

내가 그와 함께했지만 여전히 운 .. –

+0

당신은 또한 오류의 스크린 샷과 Proguard와 파일을 지킬 수 있습니까? – ABDevelopers

+0

귀하의 검토를 위해 제 질문을 업데이트했습니다. 제발 좀 봐 주시겠습니까? –