1. Warning Msg:

'instrumentationRegistry' is deprecated. Deprecated in Java

'AndroidUnit4' is deprecated. Deprecated in Java


2. solve : 

1) build.gradle (module) 파일 > 

1.1) testImplementation 'junit:junit:4.12'  -> androidTestImplementation 'androidx.test.ext:junit:1.1.0' 대체

1.2) Gradle files have changed since last project sync. A project sync ... Sync Now 클릭

android {
...
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
...
}

dependencies {
...
// testImplementation 'junit:junit:4.12' 제거
androidTestImplementation 'androidx.test.ext:junit:1.1.0' // 추가 : junit:junit 대체
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
}


2) ExampleInstrumentedTest.kt >

2.1) InstrumentationRegistry.getTargetContext() -> InstrumentationRegistry.getInstrumentation().targetContext 대체


2.2) import 변경

//import android.support.test.InstrumentationRegistry -> androidx.test.platform.app.InstrumentationRegistry 대체

//import android.support.test.runner.AndroidJUnit4 -> androidx.test.ext.junit.runners.AndroidJUnit4 대체


package com.example.com

//import android.support.test.InstrumentationRegistry // deprecated
//import android.support.test.runner.AndroidJUnit4 // deprecated
import androidx.test.ext.junit.runners.AndroidJUnit4 // 추가 : deprecated 대체
import androidx.test.platform.app.InstrumentationRegistry //추가 : deprecated 대체

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
// val appContext = InstrumentationRegistry.getTargetContext() // 제거
val appContext = InstrumentationRegistry.getInstrumentation().targetContext // 추가 : deprecated 대체
assertEquals("com.example.com", appContext.packageName)
}
}


Error Message : (Lint message)

Library should be updated to be compatible with Kotlin 1.3 less... (Ctrl+F1) 

Inspection info: This inspection reports kotlinx.coroutines libraries dependencies in Gradle that should be updated in order to be compatible with Kotlin 1.3+


물론 build 는 completed successfully 이지만, 수정하자.


solution :

step1. coroutines 선언 부분 삭제

kotlin {
experimental {
coroutines
"enable"
}
}


step2. coroutines 버전 상향 1.1.1 (2019년 3월 11일 기준)

// Coroutines
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"


ext {
coroutines = '0.26.1'
coroutines = '1.1.1'
}


comments : kotlin 1.3. 버전이 출시되면서 마이그레이션 됨.


링크 참조

https://github.com/Kotlin/kotlinx.coroutines 

https://blog.jetbrains.com/kotlin/2018/09/kotlin-1-3-rc-is-here-migrate-your-coroutines/

+ Recent posts