我被要求将用于Android应用程序的Android Studio项目从目标API 22升级到目标API28。我花了一些时间来发现代码并尝试在API 28上进行构建,但是存在一个主要问题。 确实,该项目使用SimonVT的android菜单抽屉(https://github.com/SimonVT/android-menudrawer),该菜单现已弃用(自API 23开始)。
我想知道你们是否对使用什么实现方式有什么建议,以替换项目的这一特定部分(如果可能的话,应该是最近才被广泛使用的一个建议,以便保持以后在新版本的Android中使用它。
要对不推荐使用的代码进行其他说明,应在gradle文件中添加一条注释,指出net.simonvt needs android.util.floatmath which has been removed since API 23
。
此外,这是当应用程序使用SimonVT的菜单抽屉到达起点时得到的错误日志:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: ant.h2h.feelsafe, PID: 11271
java.lang.RuntimeException: Unable to start activity ComponentInfo{ant.h2h.feelsafe/ant.h2h.feelsafe.activities.ReferentMapActivity}: java.lang.UnsupportedOperationException: Can't convert value at index 2 to dimension: type=0x1c
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 2 to dimension: type=0x1c
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:736)
at net.simonvt.menudrawer.MenuDrawer.initDrawer(MenuDrawer.java:560)
at net.simonvt.menudrawer.DraggableDrawer.initDrawer(DraggableDrawer.java:176)
at net.simonvt.menudrawer.SlidingDrawer.initDrawer(SlidingDrawer.java:32)
at net.simonvt.menudrawer.MenuDrawer.<init>(MenuDrawer.java:547)
at net.simonvt.menudrawer.MenuDrawer.<init>(MenuDrawer.java:542)
at net.simonvt.menudrawer.MenuDrawer.<init>(MenuDrawer.java:538)
at net.simonvt.menudrawer.MenuDrawer.<init>(MenuDrawer.java:531)
at net.simonvt.menudrawer.DraggableDrawer.<init>(DraggableDrawer.java:159)
at net.simonvt.menudrawer.SlidingDrawer.<init>(SlidingDrawer.java:15)
at net.simonvt.menudrawer.MenuDrawer.createMenuDrawer(MenuDrawer.java:491)
at net.simonvt.menudrawer.MenuDrawer.attach(MenuDrawer.java:456)
at ant.h2h.feelsafe.activities.MenuDrawerFollow.set(MenuDrawerFollow.java:62)
at ant.h2h.feelsafe.activities.ReferentMapActivity.onCreate(ReferentMapActivity.java:106)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)