Skip to content

Commit e24b385

Browse files
authored
Upgrade Kotlin to 1.3.50, AGP to 3.5.0, and Gradle to 5.6 (airbnb#275)
This seems to fix airbnb#256. However, it didn't crash while I was developing it, started crashing somehow and even after upgrading, it crashed until I moved the function and moved it back and now it isn't crashing. I tried various combinations of running clean and rm -rf */build/**. Upgrading these things should be good anyway and hopefully it also fixes this. I also: Upgraded a few other dependencies such as AGP but the that broke robolectric so I upgraded that and removed shadows-support-v4 since jetifier now breaks on it and we don't need it anymore. Fixed a new lint error that was caught after upgrading (ArrayMap sdk check) Fixed detekt errors since I have them as a pre-push hook.
1 parent e3bfeca commit e24b385

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
buildscript {
2-
ext.kotlinVersion = '1.3.31'
2+
ext.kotlinVersion = '1.3.50'
33
ext.appCompatVersion = '1.0.2'
44
ext.recyclerViewVersion = '1.0.0'
55
ext.lifecycleVersion = '2.0.0'
6-
ext.robolectricVersion = '4.0.2'
6+
ext.robolectricVersion = '4.3'
77
ext.epoxyVersion = '3.2.0'
88
ext.moshiVersion = '1.6.0'
99
ext.koinVersion = '2.0.1'
@@ -18,7 +18,7 @@ buildscript {
1818
jcenter()
1919
}
2020
dependencies {
21-
classpath 'com.android.tools.build:gradle:3.2.1'
21+
classpath 'com.android.tools.build:gradle:3.5.0'
2222
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"
2323
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2424
classpath 'net.sf.proguard:proguard-gradle:6.1.1'

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip

mvrx/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ dependencies {
6262
testImplementation "org.mockito:mockito-core:2.25.1"
6363
testImplementation 'junit:junit:4.12'
6464
testImplementation "org.robolectric:robolectric:$robolectricVersion"
65-
testImplementation "org.robolectric:shadows-supportv4:$robolectricVersion"
6665
}
6766

6867
// Ensure custom source sets are included:

mvrx/src/main/kotlin/com/airbnb/mvrx/BaseMvRxViewModel.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ abstract class BaseMvRxViewModel<S : MvRxState>(
215215
success.metadata = successMetaData?.invoke(value)
216216
success
217217
}
218-
.onErrorReturn {
219-
if (debugMode) Log.e(tag, "Observable encountered error", it)
220-
Fail(it)
218+
.onErrorReturn { e ->
219+
if (debugMode) Log.e(tag, "Observable encountered error", e)
220+
Fail(e)
221221
}
222222
.subscribe { asyncData -> setState { stateReducer(asyncData) } }
223223
.disposeOnClear()

mvrx/src/main/kotlin/com/airbnb/mvrx/MvRxExtensions.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ inline fun <T, reified VM : BaseMvRxViewModel<S>, reified S : MvRxState> T.paren
3939
crossinline keyFactory: () -> String = { viewModelClass.java.name }
4040
): Lazy<VM> where T : Fragment, T : MvRxView = lifecycleAwareLazy(this) {
4141
requireNotNull(parentFragment) { "There is no parent fragment for ${this::class.java.simpleName}!" }
42-
val notFoundMessage by lazy { "There is no ViewModel of type ${VM::class.java.simpleName} for this Fragment!" }
43-
val factory = MvRxFactory { error(notFoundMessage) }
42+
val notFoundMessage = { "There is no ViewModel of type ${VM::class.java.simpleName} for this Fragment!" }
43+
val factory = MvRxFactory { error(notFoundMessage()) }
4444
var fragment: Fragment? = parentFragment
4545
val key = keyFactory()
4646
while (fragment != null) {
4747
try {
4848
return@lifecycleAwareLazy ViewModelProviders.of(fragment, factory).get(key, viewModelClass.java)
4949
.apply { subscribe(this@parentFragmentViewModel, subscriber = { postInvalidate() }) }
5050
} catch (e: java.lang.IllegalStateException) {
51-
if (e.message == notFoundMessage) {
51+
if (e.message == notFoundMessage()) {
5252
fragment = fragment.parentFragment
5353
} else {
5454
throw e

mvrx/src/main/kotlin/com/airbnb/mvrx/MvRxMutabilityHelper.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.airbnb.mvrx
22

3+
import android.os.Build
34
import android.util.SparseArray
45
import androidx.collection.ArrayMap
56
import androidx.collection.LongSparseArray
@@ -39,9 +40,9 @@ internal fun KClass<*>.assertImmutability() {
3940
prop.isSubtype(SparseArray::class) -> "You cannot use SparseArray for ${prop.name}.\n$IMMUTABLE_LIST_MESSAGE"
4041
prop.isSubtype(LongSparseArray::class) -> "You cannot use LongSparseArray for ${prop.name}.\n$IMMUTABLE_LIST_MESSAGE"
4142
prop.isSubtype(SparseArrayCompat::class) -> "You cannot use SparseArrayCompat for ${prop.name}.\n$IMMUTABLE_LIST_MESSAGE"
42-
prop.isSubtype(ArrayMap::class, android.util.ArrayMap::class) -> {
43-
"You cannot use ArrayMap for ${prop.name}.\n$IMMUTABLE_MAP_MESSAGE"
44-
}
43+
prop.isSubtype(ArrayMap::class) -> "You cannot use ArrayMap for ${prop.name}.\n$IMMUTABLE_MAP_MESSAGE"
44+
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
45+
prop.isSubtype(android.util.ArrayMap::class) -> "You cannot use ArrayMap for ${prop.name}.\n$IMMUTABLE_MAP_MESSAGE"
4546
prop.isSubtype(HashMap::class) -> "You cannot use HashMap for ${prop.name}.\n$IMMUTABLE_MAP_MESSAGE"
4647
prop.isSubtype(Function::class, KCallable::class) -> {
4748
"You cannot use functions inside MvRx state. Only pure data should be represented: ${prop.name}"

mvrx/src/main/kotlin/com/airbnb/mvrx/MvRxViewId.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.airbnb.mvrx
22

33
import android.os.Bundle
4-
import java.util.*
4+
import java.util.UUID
55
import kotlin.properties.ReadOnlyProperty
66
import kotlin.reflect.KProperty
77

0 commit comments

Comments
 (0)