我已经升级了Android Studio。
因此,将其升级到最新版本后,我已使用以下方式更新了我的应用程序:"shrinkResources true"
,"minifyEnabled true"
不幸的是,在某些设备上崩溃了,没有缩小,一切正常。
下面是崩溃日志:
java.lang.RuntimeException:
at android.os.AsyncTask$3.done (AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383)
at java.util.concurrent.FutureTask.setException (FutureTask.java:252)
at java.util.concurrent.FutureTask.run (FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:764)
Caused by: java.lang.ClassCastException:
at android.app.SharedPreferencesImpl.getInt (SharedPreferencesImpl.java:302)
at com.testApp.preference.WallpaperPreference.getLWPDay (WallpaperPreference.java:66)
at com.testApp.managerLWP.GetLWP.downloadHouseAds (GetLWP.java:64)
at com.testApp.managerLWP.GetLWP.doInBackground (GetLWP.java:40)
at com.testApp.managerLWP.GetLWP.doInBackground (GetLWP.java:22)
at android.os.AsyncTask$2.call (AsyncTask.java:333)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
下面是发生崩溃的名为WallpaperPreference
的类。
public class WallpaperPreference {
private Context context;
private SharedPreferences sharedPreferences;
public WallpaperPreference(Context context) {
this.context = context;
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
}
public void setLWPDay(int value) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt(Base.LWP_JSON_DAY, value);
editor.apply();
}
public int getLWPDay() {
return sharedPreferences.getInt(Base.LWP_JSON_DAY, 0);
}
}
我用过:
compileSdkVersion 29
buildToolsVersion '29.0.3'
可能是什么解决方案?谢谢。
或
它对我有用