wequick / Small

A small framework to split app into small parts
http://code.wequick.net/Small
Apache License 2.0
5.04k stars 1.11k forks source link

运行报错 Class ref in pre-verified class resolved to unexpected implementation #278

Open jiangchunyu opened 8 years ago

jiangchunyu commented 8 years ago

报错信息是

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
  at com.jcy.smalltest.lib.net.NetUtils.getInfo(NetUtils.java:19)
  at com.jcy.smalltest.app.secound.MainActivity.onResume(MainActivity.java:24)
  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
  at android.app.Activity.performResume(Activity.java:5211)
  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2780)
  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2819)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2266)
  at android.app.ActivityThread.access$600(ActivityThread.java:141)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:5103)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:525)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  at dalvik.system.NativeStart.main(Native Method)

有两个app app.main build

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile project(':lib.net')
    compile project(':lib.utils')
}

app.secound build

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile project(':lib.net')
    compile project(':lib.utils')
}

lib.net build

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'io.reactivex:rxjava:1.1.9'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile project(':jlog')
}

lib.utils build

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'io.reactivex:rxjava:1.1.9'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile project(':jlog')
}

jlog 只是一个简单的打印库

galenlin commented 8 years ago

看起来你在 lib.netlib.utils 中都引用了 project(':jlog') ,这会导致 jlog 被编译进两个插件中,导致该问题。

MakerYan commented 8 years ago

那应该怎么解决这个问题呢, 我现在也出现这个问题, sample为什么可以同时都引用lib.style或util呢?

galenlin commented 8 years ago

原则上各个 lib.* 插件之间功能应该是独立的、各司其职。 为什么大家都需要一个 jlog 呢?这个应该是架构的问题,在做插件化之前首先要把模块都解耦好了。

ChanJLee commented 8 years ago

原则上接口什么的是不能出现在两个dex中的,出现上面这种情况就是这个原因,详见源码: `/*