Getting java.lang.NoSuchMethodError: android.os.FileUtils.getFatVolumeId in 4.2.2 and later OS
Asked Answered
E

1

2

I am facing issue in service onCreate() when trying to get SD Card id. Using FileUtils class of android.os package from src-external/android-core.

mCardId =
  FileUtils.getFatVolumeId(Environment.getExternalStorageDirectory().getPath());

Crash Log :

12-31 19:55:25.804: E/AndroidRuntime(1235):
java.lang.NoSuchMethodError: android.os.FileUtils.getFatVolumeId 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
cloudtv.android.cs.service.MediaPlaybackService.onCreate(MediaPlaybackService.java:198)
12-31 19:55:25.804: E/AndroidRuntime(1235):     at
android.app.ActivityThread.handleCreateService(ActivityThread.java:2572)
12-31 19:55:25.804: E/AndroidRuntime(1235):     at
android.app.ActivityThread.access$1800(ActivityThread.java:135) 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
12-31 19:55:25.804: E/AndroidRuntime(1235):     at
android.os.Handler.dispatchMessage(Handler.java:102) 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
android.os.Looper.loop(Looper.java:136) 12-31 19:55:25.804:
E/AndroidRuntime(1235):     at
android.app.ActivityThread.main(ActivityThread.java:5017) 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
java.lang.reflect.Method.invokeNative(Native Method) 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
java.lang.reflect.Method.invoke(Method.java:515) 12-31 19:55:25.804:
E/AndroidRuntime(1235):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
12-31 19:55:25.804: E/AndroidRuntime(1235):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 12-31
19:55:25.804: E/AndroidRuntime(1235):   at
dalvik.system.NativeStart.main(Native Method)

Thanks in advance!

Elide answered 31/12, 2013 at 14:46 Comment(0)
C
5

FileUtils is a platform-internal class, annotated with @hide. You should not be using it.

Coenzyme answered 31/12, 2013 at 14:52 Comment(2)
Thanks for quick response, i am using it and working fine but issue is only from 4.2.2 and later devices.Elide
@BipinVayalu: At most, it is "working fine" on the devices you have tried. There is no requirement that any device have FileUtils, let alone any specific method on it. And, as you are discovering, there is no requirement for Google to continue offering it.Gipson

© 2022 - 2024 — McMap. All rights reserved.