有时当我调用此方法时:
public static void initImageLoader(Context context) {
int memoryCacheSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
memoryCacheSize = (memClass / 8) * 1024 * 1024; // 1/8 of app memory limit
} else {
memoryCacheSize = 2 * 1024 * 1024;
}
// This configuration tuning is custom. You can tune every option, you may tune some of them,
// or you can create default configuration by
// ImageLoaderConfiguration.createDefault(this);
// method.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCacheSize(memoryCacheSize).denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging() // Not necessary in common
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
}
调用 ImageLoaderConfiguration.Builder 时出现此错误:
Fatal Exception java.lang.NoSuchMethodError
<init>
0
TabsActivity.java line 160
com.byhours.byhours.gui.TabsActivity.initImageLoader
1
TabsActivity.java line 83
com.byhours.byhours.gui.TabsActivity.onCreate
2
Activity.java line 4470
android.app.Activity.performCreate
3
Instrumentation.java line 1052
android.app.Instrumentation.callActivityOnCreate
4
ActivityThread.java line 1931
android.app.ActivityThread.performLaunchActivity
5
ActivityThread.java line 1992
android.app.ActivityThread.handleLaunchActivity
6
ActivityThread.java line 127
android.app.ActivityThread.access$600
7 ...
ActivityThread.java line 1158
android.app.ActivityThread$H.handleMessage
8
Handler.java line 99
android.os.Handler.dispatchMessage
9
Looper.java line 137
android.os.Looper.loop
10
ActivityThread.java line 4511
android.app.ActivityThread.main
11 ...
Method.java line
java.lang.reflect.Method.invokeNative
12
Method.java line 511
java.lang.reflect.Method.invoke
13
ZygoteInit.java line 986
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
14
ZygoteInit.java line 753
com.android.internal.os.ZygoteInit.main
15
NativeStart.java line
dalvik.system.NativeStart.main
我该如何解决?