Adding dependency results in ClassNotFoundException in other dependency

Hi,

I have a project A with the following dependencies:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'org.json:json:20171018'
    implementation 'junit:junit:4.12'
}

And some project B that depends on A:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':A')
    implementation 'org.json:json:20171018'
}

If I run project B, I get this exception: java.lang.ClassNotFoundException: org.json.JSONException. But if I remove the dependency on org.json from project B, everything works fine.

Any idea what the reason for this behavior is?