例外情况仅发生在Android 7.0 Nougat(模拟器)设备中.
java.lang.SecurityException:不再支持MODE_WORLD_READABLE
我的代码:
public void SessionMaintainence(Context context) {
this.context = context;
preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_WORLD_READABLE);
editor = preferences.edit();
editor.commit();
}
Run Code Online (Sandbox Code Playgroud)
logcat的:
> E/AndroidRuntime: FATAL EXCEPTION: main
> Process: burpp.av.feedback, PID: 2796
> java.lang.RuntimeException: Unable to create application
> burpp.av.feedback.FeedbackApplication: java.lang.SecurityException:
> MODE_WORLD_READABLE no longer supported
> at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5364)
> at android.app.ActivityThread.-wrap2(ActivityThread.java)
> at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:154)
> at android.app.ActivityThread.main(ActivityThread.java:6077)
> at java.lang.reflect.Method.invoke(Native Method)
> at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
> Caused by: java.lang.SecurityException: MODE_WORLD_READABLE …Run Code Online (Sandbox Code Playgroud) android android-securityexception android-sharedpreferences android-7.0-nougat
项目"FeedBack"可能正在使用不包含该方法的Android Gradle插件版本(例如,在1.1.0中添加了"testCompile").修复插件版本和同步项目 项目"FeedBack"可能正在使用不包含该方法的Gradle版本.打开Gradle包装文件 构建文件可能缺少Gradle插件.应用Gradle插件
//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
Run Code Online (Sandbox Code Playgroud)
//模块:app gradle文件
apply plugin: 'com.android.application'
apply plugin: …Run Code Online (Sandbox Code Playgroud) android ×2