Exception Ljava/lang/NullPointerException; thrown while initializing Landroid/os/debug

 
 

W/Environment(  784): EXTERNAL_STORAGE undefined; falling back to default
W/dalvikvm(  784): Exception Ljava/lang/NullPointerException; thrown while initializing Landroid/os/Debug;
E/Zygote  (  784): Error preloading android.R$styleable.
E/Zygote  (  784): java.lang.ExceptionInInitializerError
E/Zygote  (  784):      at com.android.internal.os.ZygoteInit.preloadClasses(ZygoteInit.java:294)
E/Zygote  (  784):      at com.android.internal.os.ZygoteInit.preload(ZygoteInit.java:231)
E/Zygote  (  784):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
E/Zygote  (  784):      at dalvik.system.NativeStart.main(Native Method)
E/Zygote  (  784): Caused by: java.lang.NullPointerException
E/Zygote  (  784):      at java.io.File.fixSlashes(File.java:185)
E/Zygote  (  784):      at java.io.File.<init>(File.java:134)
E/Zygote  (  784):      at android.os.Environment.getLegacyExternalStorageDirectory(Environment.java:390)
E/Zygote  (  784):      at android.os.Debug.<clinit>(Debug.java:98)
E/Zygote  (  784):      ... 4 more


原因是debug.java中有一句话: 

private static final String DEFAULT_TRACE_PATH_PREFIX =
        Environment.getLegacyExternalStorageDirectory().getPath() + "/";
这里会去获取外部存储设备EXTERNAL_STORAGE, 如果没有定义这个宏, 就会使用默认的 /storage/sdcard0


init.rc里面会创建/storage, 但是不会创建sdcard0, 所以我们需要在自己的init.xxx.rc里面创建/storage/sdcard0

你可能感兴趣的:(Exception Ljava/lang/NullPointerException; thrown while initializing Landroid/os/debug)