Skip to content

Commit

Permalink
fixing some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
sockeqwe committed Oct 13, 2016
1 parent 2ff7f92 commit b65c43e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion _posts/2016-10-13-library-abstract-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ What if you decide to update your app to version 2.1 (with payload support) but

![dependencies](/images/adapterdelegates/dependencies.png)

Then your code will compile but your app will crash at runtime. Why? Because the third party library is already compiled. Hence, no compile time error will be thrown but gradle will pack version 2.1 (can't pack both 2.1 and 2.0 in the same apk, therefore uses the newer one) into your final android APK file. Then when invoking `onBindViewHolder(VH holder, int position, List<Object> payloads)` on a third party library component a `NoSuchMethodError` will be thrown at runtime. The android SDK faces the same issue. LINT warns you to add a check like `if (VERSION.SDK_INT >= 21)` but there is no such mechanism for libraries packed in your code.
Then your code will compile but your app will crash at runtime. Why? Because the third party library is already compiled. Hence, no compile time error will be thrown but gradle will pack version 2.1 (can't pack both 2.1 and 2.0 in the same apk, therefore uses the newer one) into your final android APK file. When invoking `onBindViewHolder(VH holder, int position, List<Object> payloads)` on a third party library component a `NoSuchMethodError` will be thrown at runtime. The android SDK faces the same issue. LINT warns you to add a check like `if (VERSION.SDK_INT >= 21)` but there is no such mechanism for libraries packed in your code.

To avoid such problems Jake Wharton suggested to change package name and maven group id in his blog post [Java Interoperability Policy for Major Version Updates](http://jakewharton.com/java-interoperability-policy-for-major-version-updates/).
That is a very good strategy you should follow when publishing your own library. But what is a major version update? In my case, every time RecyclerView's Adapter changes his API that would be a major version update for my AdapterDelegates library too because I may have to add new methods to the `interface AdapterDelegate<T>`. That wouldn't be very inconvenient for the users of my library.
Expand Down

0 comments on commit b65c43e

Please sign in to comment.