android java.lang.IncompatibleClassChangeError: Superclass org.apache.http.p

错误提示:

java.lang.IncompatibleClassChangeError: org.apache.http.params.SyncBasicHttpParams
    at dalvik.system.DexFile.defineClassNative(Native Method)
    at dalvik.system.DexFile.defineClass(DexFile.java:226)
    at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
    at dalvik.system.DexPathList.findClass(DexPathList.java:321)
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:308)
    at com.activeandroid.ModelInfo.scanForModelClasses(ModelInfo.java:187)
    at com.activeandroid.ModelInfo.scanForModel(ModelInfo.java:152)
    at com.activeandroid.ModelInfo.(ModelInfo.java:63)
    at com.activeandroid.Cache.initialize(Cache.java:66)
    at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
    at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
    at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:30)
    at com.eebbk.syncpointread.base.EnglishReadApplication$14.run(EnglishReadApplication.java:254)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:818)
 

解决方法:

1 ActiveAndroid 集成
repositories {

        google()
        jcenter()

        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

}

compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
2 在 MyApplication 中调用 ActiveAndroid.initialize(this);
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        ActiveAndroid.initialize(this);
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        ActiveAndroid.dispose();
    }
}
3 在 AndroidManifest.xml 文件仲 Application 标签下添加.
        

问题解决。

或者参考 github demo: DemoPardomORM

你可能感兴趣的:(android java.lang.IncompatibleClassChangeError: Superclass org.apache.http.p)