简体   繁体   中英

How to deprecate a package in android

In my android project (Windows 7, Android Studio 2.2.3 with java 1.8.0_76-release-b03 amd64, gradle 2.14.1) I tried to deprecate one of my packages using the package-info.java file (as suggested in https://stackoverflow.com/a/23019294 ) like this:

/**
 * @deprecated As of 22.02.2017 
 */
@Deprecated
package com.x.y;

But got the following compilation error:

PathtoProject\\app\\src\\main\\java\\com\\x\\y\\package-info.java:5:error: modifier deprecated not allowed here package com.xy;

Why is this error ocurring? And what's the correct way to make a package deprecated?

Somebody else seemed to have had this problem as well and it didn't get resolved: https://code.google.com/p/android/issues/detail?id=233212

  • Package cannot be deprecated only classes can be deprecated see this .

  • Also according to this , packages are meant for managing the classes in an organised way and also to avoid class name collisions.

  • So instead of annotating a package with @Deprecated annotate all public classes of the with @Deprecated

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM