java.lang.ClassNotFoundException:找不到类“ io.reactivex.subjects.PublishSubject”

时间:2019-07-03 15:38:48

标签: android proguard rx-java2

我已经使用Rxjava2和其他库创建了一个库项目。 我已经使用proguard生成了aar文件。

在示例应用程序中使用库时,我崩溃了

java.lang.NoClassDefFoundError: Failed resolution of: Lio/reactivex/subjects/PublishSubject;
    at b.a.a.d.d.<init>(Unknown Source:3)
    at b.a.a.d.d.a(Unknown Source:13)
    at com.sample.MySDK.init(Unknown Source:6)
    at com.sample.MainActivity.initializeSDK(MainActivity.java:105)
    at com.sample.MainActivity.access$100(MainActivity.java:31)
    at com.sample.MainAhere`ctivity$3.onResponse(MainActivity.java:92)

1 个答案:

答案 0 :(得分:1)

我的猜测是您的库正在使用reorderer_list引入RxJava依赖关系。库通常使用# This will find the differences between the reordered list and the original list changedOrderItems = [] changedOrderItemsOrders = [] for index, product in enumerate(list_data): #Sizes may be different, avoid IndexError if index == len(reorderer_list): break # Is different if product.name != reorderer_list[index]["name"]: #Append to temporary list, the items from reorderer list changedOrderItems.append(reorderer_list[index]) #Append to temporary list, the order property of these items changedOrderItemsOrders.append(reorderer_list[index]["order"]) #Sort the orders list changedOrderItemsOrders.sort() # Cycles through the temporary list and finds the index of the respective object in the original list and sets it's order number according to the sorted changedOrderItemsOrders list for i, item in enumerate(changedOrderItems): from_data_index = next((index for (index, d) in enumerate(list_data) if d.name == item["name"]), None) list_data[from_data_index].order = changedOrderItemsOrders[i] 来实现这种依赖关系,因此使用该库的应用程序通过可传递依赖关系将RxJava引入。