How to ignore java.time package in Android Studio
Asked Answered
P

1

6

I am currently working on an Android Studio project with a minimum API version of 17 (JellyBean), so I cannot use the java.time package. Instead, I am using the ThreeTen backport for Android (com.jakewharton.threetenabp:threetenabp:1.1.0).

My problem is that every class in com.threeten.bp matches one in java.time, and I find that it is very easy to accidentally import the wrong class, since the auto-complete popup shows the java.time option first. I need a way to just remove that java.time package from my project, or at least tell Android Studio to ignore it. Is it possible to do that?

Pandect answered 7/7, 2018 at 12:27 Comment(1)
You cannot remove it from the project, other than by setting a low enough compileSdkVersion, from before java.time was added. That won't work very well for the rest of your app, though. I don't know if there is a way to tailor auto-complete to filter out certain packages, though that sounds like a nice feature.Sheley
S
5

You can disable auto-import classes of this package. Add java.time into:

Editor--> General --> Auto import --> exclude from import and completion
Shad answered 7/7, 2018 at 12:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.