r/androiddev • You will pry XML Views from my cold dead hands • Feb 24 '21

Discussion Android Deprecated Annotation is deprecated.

According to Official Android Documentation Deprecated itself is deprecated in API level S. So what's the replacement for Deprecated which itself is deprecated?

228 Upvotes

46 comments sorted by

77

u/tnorbye Android Studio Team Feb 24 '21

It's not deprecated!

This was a mistake in the platform build tooling (and yes, it's my fault, it's a bug in code I wrote -- https://android.googlesource.com/platform/tools/metalava/+/957c774b622d06b29c4c59e48db59e2e7f2ae734/src/main/java/com/android/tools/metalava/model/psi/PsiModifierItem.kt#230). This also picks up mentions of @deprecated in things like {@code} blocks which it should not. This bug has gone undetected for years... For now it's solved by using escapes to trick metalava into not recognizing @deprecated, but the proper fix will be to properly tokenize the javadoc (which we do in some other places to resolve relative imports for example.)

14

u/ComfortablyBalanced You will pry XML Views from my cold dead hands Feb 24 '21

Thank you for all the good you do for Android Development platform. Yeah it seemed very odd that it was deprecated and thank you again for your clarification.

11

u/tnorbye Android Studio Team Feb 24 '21

....and here's the workaround, h/t to /u/nic0lette

2

u/ballzak69 Feb 25 '21

Please also fix the @Removed issue while you're at it!

1

u/blinksd Mar 02 '21 edited Mar 02 '21

you can try to use reflection for old Android versions

1

u/ballzak69 Mar 02 '21

Sure, but that shouldn't be needed for a public API still in use. Also, the removed methods can can no longer be found in the official Android documentation.

1

u/blinksd Mar 03 '21

you can find old codes at Google's git, with documentations in codes https://android.googlesource.com/platform/frameworks/base

1

u/ballzak69 Mar 03 '21

I know the methods was public, and where to look, but other developers may not. Please stop belittling the issue.

55

u/gold_rush_doom Feb 24 '21

I'm guessing it will be moved to the androidx annotations library.

77

u/ComfortablyBalanced You will pry XML Views from my cold dead hands Feb 24 '21

Yeah, let's rename it to androidx.DeprecatedCompat then.

59

u/DrSheldonLCooperPhD Feb 24 '21
androidx.deprecated:deprecated:1.0.0-alpha44

FTFY

25

u/nakkht Feb 24 '21

Ready for production.

5

u/house_monkey Feb 24 '21

I'd deploy

12

u/[deleted] Feb 24 '21

No, that's preserved for all the Compat stuff that was deprecated but is still maintained!

4

u/AD-LB Feb 24 '21

So what should be used instead? Why for almost all cases I see this annotation, there is no clue about what to use, and how...

1

u/sandeep_r_89 Feb 25 '21

They usually include some alternative in the javadoc. Or maybe it was written about in a blog post/Android dev website.

1

u/AD-LB Feb 25 '21

I'm talking about Android development. Many times there, there is no proper explanation (or even a clue/mention) of what to use instead.

In the beginning I tried to go deep into docs, and most of the times I didn't see anything, so today I go directly to StackOverflow and Google-search instead.

5

u/Frission_ Feb 24 '21

This is the way

1

u/pjmlp Feb 25 '21

Nah, they need to rewrite it in Kotlin first. /s

1

u/alanviverette Android Feb 26 '21

I mean, it would be nice to get a Java port of the @kotlin.Deprecated annotation's replaceWith functionality.

9

u/motivateddeveloper Feb 24 '21

Look how the turntables

3

u/ComfortablyBalanced You will pry XML Views from my cold dead hands Feb 24 '21

Well well well well well well!

19

u/nic0lette Android DevRel Feb 24 '21

19

u/arunkumar9t2 Feb 24 '21

This thread is deprecated now.

10

u/[deleted] Feb 24 '21

hold up, so it's not deprecated then?

8

u/sirmonko Feb 24 '21

the depreciation of the depreciation has been depreciated.

1

u/sandeep_r_89 Feb 25 '21

So, does that mean my car value appreciates when we roll it off the dealer's lot?

3

u/sirmonko Feb 25 '21

this actually happened with certain cars for some time. the dacia sold used for more than new, because they were sold out and still cheaper than other cars.

another upside was that they didn't run on Android and were thus safe from depreciation.

26

u/can_i_have Feb 24 '21

The Deprecated APIs will now get an obscure warning email every time they are used. By a bot. It'll warn them that they're doing something undesirable but will not exactly tell what. This counts as a strike. The appeals process will be there. It'll be obscure too but in a worse worse way.

Upon three, or a random lesser no of, such strikes, their accounts will be banned and all the other methods in the same class get banned too. Just because.

10

u/NahroT Feb 24 '21

This is the best day of my life

8

u/pcoyuncy Feb 24 '21

Perfectly balanced, as all things should be.

7

u/infinity1one Feb 24 '21

DeprecatedX

8

u/greenrobot_de Feb 24 '21

That's so Android!

16

u/Tolriq Feb 24 '21

They now directly remove things no need to care about devs :)

6

u/sammndl01 Feb 24 '21

Lol like they did care when after the introduction of Marshmallow, we had to use content instead of file to save something on external storage. Could've kept it and saved us Java programmers hours of searching on stackoverflow and increasing boilerplate code.

7

u/DrSheldonLCooperPhD Feb 24 '21

Glad I am not the only one who feel this way.

Android development right now is unnecessary refactors, alpha dump, Google search ads for developer tools and Android Studio scores based on libraries you are using. I bet even serious Google apps don't use them.

Must really suck to be a new comer to Android dev today.

6

u/TotesMessenger Feb 24 '21

I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:

 If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)

3

u/[deleted] Feb 24 '21

Thus the circle completes.

4

u/Nihil227 Feb 24 '21

Deprecated Deprecated Deprecated Deprecated

3

u/khsh01 Feb 24 '21

It's funny how this is completely normal for Android developers. In any other context this would be taken as a joke.

3

u/AD-LB Feb 24 '21

This means nothing will be deprecated anymore, as it shouldn't have a deprecation annotation!

:)

26

u/[deleted] Feb 24 '21

[removed] — view removed comment

10

u/AD-LB Feb 24 '21

Or better: nothing should be marked as deprecated anymore, because it's deprecated.