AndroidJUnit4.class is deprecated: How to use androidx.test.ext.junit.runners.AndroidJUnit4?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
For my instrumentation tests I was using
@RunWith(AndroidJUnit4.class)
from
import androidx.test.runner.AndroidJUnit4;
in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4
from
import androidx.test.ext.junit.runners.AndroidJUnit4
However if I try to import AndroidJUnit4
from the named package I get the error, that ext
can not be resolved.
Do you have an idea, what package should be included in gradle to resolve this issue?
android junit android-testing androidx
add a comment |
For my instrumentation tests I was using
@RunWith(AndroidJUnit4.class)
from
import androidx.test.runner.AndroidJUnit4;
in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4
from
import androidx.test.ext.junit.runners.AndroidJUnit4
However if I try to import AndroidJUnit4
from the named package I get the error, that ext
can not be resolved.
Do you have an idea, what package should be included in gradle to resolve this issue?
android junit android-testing androidx
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
2
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48
add a comment |
For my instrumentation tests I was using
@RunWith(AndroidJUnit4.class)
from
import androidx.test.runner.AndroidJUnit4;
in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4
from
import androidx.test.ext.junit.runners.AndroidJUnit4
However if I try to import AndroidJUnit4
from the named package I get the error, that ext
can not be resolved.
Do you have an idea, what package should be included in gradle to resolve this issue?
android junit android-testing androidx
For my instrumentation tests I was using
@RunWith(AndroidJUnit4.class)
from
import androidx.test.runner.AndroidJUnit4;
in order to establish my test cases. Now this line gets marked as deprecated with the hint to use AndroidJUnit4
from
import androidx.test.ext.junit.runners.AndroidJUnit4
However if I try to import AndroidJUnit4
from the named package I get the error, that ext
can not be resolved.
Do you have an idea, what package should be included in gradle to resolve this issue?
android junit android-testing androidx
android junit android-testing androidx
asked Oct 12 '18 at 9:40
Marcel GangwischMarcel Gangwisch
1,8562923
1,8562923
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
2
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48
add a comment |
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
2
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
2
2
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48
add a comment |
2 Answers
2
active
oldest
votes
According to the documentation for AndroidJUnit4, the gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
After adding this, everything worked for me.
If it still doesn't work, make sure that you clean and/or rebuild your project.
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
|
show 1 more comment
In my case changing androidTestImplementation
to testImplementation
helped.
I did't know the difference before reading this android difference between testImplementation and androidTestImplementation in build.gradle
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52776716%2fandroidjunit4-class-is-deprecated-how-to-use-androidx-test-ext-junit-runners-an%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the documentation for AndroidJUnit4, the gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
After adding this, everything worked for me.
If it still doesn't work, make sure that you clean and/or rebuild your project.
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
|
show 1 more comment
According to the documentation for AndroidJUnit4, the gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
After adding this, everything worked for me.
If it still doesn't work, make sure that you clean and/or rebuild your project.
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
|
show 1 more comment
According to the documentation for AndroidJUnit4, the gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
After adding this, everything worked for me.
If it still doesn't work, make sure that you clean and/or rebuild your project.
According to the documentation for AndroidJUnit4, the gradle file should contain the following line:
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
After adding this, everything worked for me.
If it still doesn't work, make sure that you clean and/or rebuild your project.
edited Mar 19 at 3:56
Cody Gray♦
195k35383475
195k35383475
answered Oct 12 '18 at 9:53
Marcel GangwischMarcel Gangwisch
1,8562923
1,8562923
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
|
show 1 more comment
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
5
5
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
my gradle has this and still cannot resolve the issue.
– zuko
Dec 1 '18 at 18:10
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@zuko Clean and/or rebuild your project, it should be there. If still not and you're using modules, check that your dependency hierarchy is setup as you expect; you might need to add these to the top level modules too—since testing libraries aren't compiled into shared modules for use by upstream modules.
– Jon Adams
Dec 28 '18 at 1:58
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
@JonAdams my dependency tree kept holding onto a reference to older libraries for some reason even though i thought i removed them. so after trying various things i ended up just migrating the project to a new one and everything is fine now.
– zuko
Dec 29 '18 at 20:50
2
2
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
Should we also change testInstrumentationRunner in the gradle file from androidx.test.runner.AndroidJUnitRunner to androidx.test.ext.junit.runners.AndroidJUnit4? Just wondering if there's a mismatch.
– A Droid
Feb 2 at 9:17
3
3
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
@A Droid Replace old AndroidJUnit4 package in import with new one. Just Replace import androidx.test.runner.AndroidJUnit4; with import androidx.test.ext.junit.runners.AndroidJUnit4;
– Xplosive
Feb 8 at 19:15
|
show 1 more comment
In my case changing androidTestImplementation
to testImplementation
helped.
I did't know the difference before reading this android difference between testImplementation and androidTestImplementation in build.gradle
add a comment |
In my case changing androidTestImplementation
to testImplementation
helped.
I did't know the difference before reading this android difference between testImplementation and androidTestImplementation in build.gradle
add a comment |
In my case changing androidTestImplementation
to testImplementation
helped.
I did't know the difference before reading this android difference between testImplementation and androidTestImplementation in build.gradle
In my case changing androidTestImplementation
to testImplementation
helped.
I did't know the difference before reading this android difference between testImplementation and androidTestImplementation in build.gradle
answered Mar 21 at 20:06
Krzysztof DziubaKrzysztof Dziuba
32738
32738
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52776716%2fandroidjunit4-class-is-deprecated-how-to-use-androidx-test-ext-junit-runners-an%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
stackoverflow.com/questions/43342831/…
– IntelliJ Amiya
Oct 12 '18 at 9:44
2
I think your source is obsolet, they do not mention androidx at all.
– Marcel Gangwisch
Oct 12 '18 at 9:48