{"action":"created","issue":{"url":"https://api.github.com/repos/square/okhttp/issues/2243","labels_url":"https://api.github.com/repos/square/okhttp/issues/2243/labels{/name}","comments_url":"https://api.github.com/repos/square/okhttp/issues/2243/comments","events_url":"https://api.github.com/repos/square/okhttp/issues/2243/events","html_url":"https://github.com/square/okhttp/issues/2243","id":126693456,"number":2243,"title":"Could not use 'com.squareup.okhttp3:okhttp-urlconnection:3.0.0' (gradle)","user":{"login":"BoD","id":372852,"avatar_url":"https://avatars.githubusercontent.com/u/372852?v=3","gravatar_id":"","url":"https://api.github.com/users/BoD","html_url":"https://github.com/BoD","followers_url":"https://api.github.com/users/BoD/followers","following_url":"https://api.github.com/users/BoD/following{/other_user}","gists_url":"https://api.github.com/users/BoD/gists{/gist_id}","starred_url":"https://api.github.com/users/BoD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BoD/subscriptions","organizations_url":"https://api.github.com/users/BoD/orgs","repos_url":"https://api.github.com/users/BoD/repos","events_url":"https://api.github.com/users/BoD/events{/privacy}","received_events_url":"https://api.github.com/users/BoD/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-14T16:39:04Z","updated_at":"2016-01-14T20:13:33Z","closed_at":null,"body":"I am building an Android app.\r\nWhen declaring these 2 dependencies:\r\n```\r\n    compile 'com.squareup.okhttp3:okhttp:3.0.0'\r\n    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.0'\r\n```\r\nmy build fails with this error:\r\n```\r\nUNEXPECTED TOP-LEVEL EXCEPTION:\r\ncom.android.dex.DexException: Multiple dex files define Lokhttp3/Address;\r\n        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)\r\n        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)\r\n        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)\r\n        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)\r\n        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)\r\n        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)\r\n        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)\r\n        at com.android.dx.command.dexer.Main.run(Main.java:277)\r\n        at com.android.dx.command.dexer.Main.main(Main.java:245)\r\n        at com.android.dx.command.Main.main(Main.java:106)\r\n```\r\nWhen looking at `okhttp-urlconnection.jar` I was surprised to see this class indeed present inside.  I am not sure if this is normal.\r\n\r\nI tried to be clever and declare instead these dependencies:\r\n```\r\n//    compile 'com.squareup.okhttp3:okhttp:3.0.0'\r\n    compile ('com.squareup.okhttp3:okhttp-urlconnection:3.0.0') { exclude group: 'com.squareup.okhttp3' }\r\n```\r\n(notice the first declaration is commented out)\r\n\r\nNow the build succeeds.  But my app fails at runtime, with this exception:\r\n```\r\njava.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/tls/OkHostnameVerifier;\r\n                                                                                            at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.java:340)\r\n                                                                                            at okhttp3.OkHttpClient.<init>(OkHttpClient.java:147)\r\n                                                                                            at myapp.backend.net.MultipartHttpClient.getOkHttpClient(MultipartHttpClient.java:166)\r\n                                                                                            at myapp.backend.net.MultipartHttpClient.getMultipartClientHttpRequest(MultipartHttpClient.java:135)\r\n                                                                                            at myapp.backend.net.MultipartHttpClient.doHttpCall(MultipartHttpClient.java:273)\r\n                                                                                            at myapp.core.codec.impl.ApiClientRequestImpl.doRequest(ApiClientRequestImpl.java:307)\r\n                                                                                            at myapp.GcmReceiver.sendDeviceSetConfig(GcmReceiver.java:173)\r\n                                                                                            at myapp.GcmReceiver$1.background(GcmReceiver.java:83)\r\n                                                                                            at myapp.SimpleAsyncTask.doInBackground(SimpleAsyncTask.java:32)\r\n                                                                                            at myapp.util.SimpleAsyncTask.doInBackground(SimpleAsyncTask.java:16)\r\n                                                                                            at android.os.AsyncTask$2.call(AsyncTask.java:288)\r\n                                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:237)\r\n                                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)\r\n                                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)\r\n                                                                                            at java.lang.Thread.run(Thread.java:818)\r\n                                                                                         Caused by: java.lang.ClassNotFoundException: Didn't find class \"okhttp3.internal.tls.OkHostnameVerifier\" on path: DexPathList[[zip file \"/data/app/com.familyandco.mifamily.dev-2/base.apk\"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]\r\n                                                                                            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)\r\n                                                                                            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)\r\n                                                                                            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)\r\n                                                                                            at okhttp3.OkHttpClient$Builder.<init>(OkHttpClient.java:340) \r\n                                                                                            at okhttp3.OkHttpClient.<init>(OkHttpClient.java:147) \r\n                                                                                            at myapp.backend.net.MultipartHttpClient.getOkHttpClient(MultipartHttpClient.java:166) \r\n                                                                                            at myapp.backend.net.MultipartHttpClient.getMultipartClientHttpRequest(MultipartHttpClient.java:135) \r\n                                                                                            at myapp.backend.net.MultipartHttpClient.doHttpCall(MultipartHttpClient.java:273) \r\n                                                                                            at myapp.core.codec.impl.ApiClientRequestImpl.doRequest(ApiClientRequestImpl.java:307) \r\n                                                                                            at myapp.gcm.GcmReceiver.sendDeviceSetConfig(GcmReceiver.java:173) \r\n                                                                                            at myapp.gcm.GcmReceiver$1.background(GcmReceiver.java:83) \r\n                                                                                            at myapp.util.SimpleAsyncTask.doInBackground(SimpleAsyncTask.java:32) \r\n                                                                                            at myapp.util.SimpleAsyncTask.doInBackground(SimpleAsyncTask.java:16) \r\n                                                                                            at android.os.AsyncTask$2.call(AsyncTask.java:288) \r\n                                                                                            at java.util.concurrent.FutureTask.run(FutureTask.java:237) \r\n                                                                                            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) \r\n                                                                                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) \r\n                                                                                            at java.lang.Thread.run(Thread.java:818) \r\n                                                                                        \tSuppressed: java.lang.ClassNotFoundException: okhttp3.internal.tls.OkHostnameVerifier\r\n                                                                                            at java.lang.Class.classForName(Native Method)\r\n                                                                                            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)\r\n                                                                                            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)\r\n                                                                                            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)\r\n                                                                                            \t\t... 16 more\r\n                                                                                         Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available\r\n```\r\n\r\nWeird?"},"comment":{"url":"https://api.github.com/repos/square/okhttp/issues/comments/171766804","html_url":"https://github.com/square/okhttp/issues/2243#issuecomment-171766804","issue_url":"https://api.github.com/repos/square/okhttp/issues/2243","id":171766804,"user":{"login":"iNoles","id":49764,"avatar_url":"https://avatars.githubusercontent.com/u/49764?v=3","gravatar_id":"","url":"https://api.github.com/users/iNoles","html_url":"https://github.com/iNoles","followers_url":"https://api.github.com/users/iNoles/followers","following_url":"https://api.github.com/users/iNoles/following{/other_user}","gists_url":"https://api.github.com/users/iNoles/gists{/gist_id}","starred_url":"https://api.github.com/users/iNoles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iNoles/subscriptions","organizations_url":"https://api.github.com/users/iNoles/orgs","repos_url":"https://api.github.com/users/iNoles/repos","events_url":"https://api.github.com/users/iNoles/events{/privacy}","received_events_url":"https://api.github.com/users/iNoles/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T20:13:33Z","updated_at":"2016-01-14T20:13:33Z","body":"@BoD If you comments main okhttp3 dependencies, why you still have exclude line on the urlconnection one?"}}