{"action":"created","issue":{"url":"https://api.github.com/repos/ngocchung/android-api23/issues/1","labels_url":"https://api.github.com/repos/ngocchung/android-api23/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ngocchung/android-api23/issues/1/comments","events_url":"https://api.github.com/repos/ngocchung/android-api23/issues/1/events","html_url":"https://github.com/ngocchung/android-api23/issues/1","id":102963467,"number":1,"title":"Compile issues","user":{"login":"smarek","id":384824,"avatar_url":"https://avatars.githubusercontent.com/u/384824?v=3","gravatar_id":"","url":"https://api.github.com/users/smarek","html_url":"https://github.com/smarek","followers_url":"https://api.github.com/users/smarek/followers","following_url":"https://api.github.com/users/smarek/following{/other_user}","gists_url":"https://api.github.com/users/smarek/gists{/gist_id}","starred_url":"https://api.github.com/users/smarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarek/subscriptions","organizations_url":"https://api.github.com/users/smarek/orgs","repos_url":"https://api.github.com/users/smarek/repos","events_url":"https://api.github.com/users/smarek/events{/privacy}","received_events_url":"https://api.github.com/users/smarek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-25T06:57:32Z","updated_at":"2015-08-25T07:31:58Z","closed_at":null,"body":"Using Gradle\r\nApply diff\r\n```diff\r\ndiff --git a/app/build.gradle b/app/build.gradle\r\nindex 89abce0..b11f02e 100644\r\n--- a/app/build.gradle\r\n+++ b/app/build.gradle\r\n@@ -27,6 +27,6 @@ android {\r\n }\r\n \r\n dependencies {\r\n-    compile fileTree(dir: 'libs', include: ['*.jar'])\r\n     compile 'com.android.support:appcompat-v7:23.0.0'\r\n+    compile 'org.apache.httpcomponents:httpclient:4.4.1'\r\n }\r\ndiff --git a/build.gradle b/build.gradle\r\nindex 1b7886d..c6371d6 100644\r\n--- a/build.gradle\r\n+++ b/build.gradle\r\n@@ -5,7 +5,7 @@ buildscript {\r\n         jcenter()\r\n     }\r\n     dependencies {\r\n-        classpath 'com.android.tools.build:gradle:1.3.0'\r\n+        classpath 'com.android.tools.build:gradle:1.3.1'\r\n \r\n         // NOTE: Do not place your application dependencies here; they belong\r\n         // in the individual module build.gradle files\r\n```\r\nrun `gradle assemble` or `gradle check` on project, get this output:\r\n```\r\n> gradle check\r\nWARNING: Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.\r\n         In case of problem, please repackage it with jarjar to change the class packages\r\nWARNING: Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android.\r\n         In case of problem, please repackage it with jarjar to change the class packages\r\nWARNING: Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android.\r\n         In case of problem, please repackage it with jarjar to change the class packages\r\nWARNING: Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for release as it may be conflicting with the internal version provided by Android.\r\n         In case of problem, please repackage it with jarjar to change the class packages\r\n:app:preBuild UP-TO-DATE\r\n:app:preDebugBuild UP-TO-DATE\r\n:app:checkDebugManifest\r\n// ... build output continues\r\n```\r\n\r\nWith dependencies tree like this:\r\n```\r\ncompile - Classpath for compiling the main sources.\r\n\\--- org.apache.httpcomponents:httpclient:4.4.1\r\n     +--- org.apache.httpcomponents:httpcore:4.4.1\r\n     +--- commons-logging:commons-logging:1.2\r\n     \\--- commons-codec:commons-codec:1.9\r\n```\r\n\r\nSo I guess Gradle doesn't check JAR dependencies for compatibility issues.\r\n\r\nBecause when I place this code within `onCreate` (your code had no side effect, so it may have been stripped by compiler)\r\n```java\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_main);\r\n\r\n        CloseableHttpClient chc = HttpClients.createDefault();\r\n        try {\r\n            CloseableHttpResponse chr = chc.execute(new HttpGet(\"https://www.google.com\"));\r\n            for (Header h : chr.getAllHeaders()) {\r\n                Log.d(\"MainActivity\", String.format(\"%s = %s\", h.getName(), h.getValue()));\r\n            }\r\n            chr.close();\r\n            chc.close();\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        }\r\n    }\r\n```\r\nwhich is basically minimal sample from https://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html\r\n\r\nI'll get StackTrace like this:\r\n```\r\n08-25 08:55:38.033  29232-29232/? E/AndroidRuntime﹕ FATAL EXCEPTION: main\r\n    Process: com.example.api23, PID: 29232\r\n    java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/message/BasicLineFormatter; in class Lorg/apache/http/message/BasicLineFormatter; or its superclasses (declaration of 'org.apache.http.message.BasicLineFormatter' appears in /system/framework/ext.jar)\r\n            at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)\r\n            at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)\r\n            at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)\r\n            at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:72)\r\n            at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<init>(ManagedHttpClientConnectionFactory.java:84)\r\n            at org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.<clinit>(ManagedHttpClientConnectionFactory.java:59)\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:487)\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:147)\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:136)\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:112)\r\n            at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:726)\r\n            at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)\r\n            at com.example.api23.MainActivity.onCreate(MainActivity.java:26)\r\n            at android.app.Activity.performCreate(Activity.java:5990)\r\n            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)\r\n            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)\r\n            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2418)\r\n            at android.app.ActivityThread.access$900(ActivityThread.java:154)\r\n            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)\r\n            at android.os.Handler.dispatchMessage(Handler.java:102)\r\n            at android.os.Looper.loop(Looper.java:135)\r\n            at android.app.ActivityThread.main(ActivityThread.java:5289)\r\n            at java.lang.reflect.Method.invoke(Native Method)\r\n            at java.lang.reflect.Method.invoke(Method.java:372)\r\n            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)\r\n            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)\r\n08-25 08:55:43.710  29232-29245/com.example.api23 E/System﹕ Uncaught exception thrown by finalizer\r\n08-25 08:55:43.711  29232-29245/com.example.api23 E/System﹕ java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.http.impl.conn.CPool.shutdown()' on a null object reference\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.shutdown(PoolingHttpClientConnectionManager.java:347)\r\n            at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.finalize(PoolingHttpClientConnectionManager.java:168)\r\n            at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:191)\r\n            at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:174)\r\n            at java.lang.Thread.run(Thread.java:818)\r\n```\r\n\r\nWhich is caused by known conflict of Classpaths on Android, for reference see ie. this:\r\nhttps://stackoverflow.com/questions/27721086/error-runing-app-with-apache-http-libs"},"comment":{"url":"https://api.github.com/repos/ngocchung/android-api23/issues/comments/134510509","html_url":"https://github.com/ngocchung/android-api23/issues/1#issuecomment-134510509","issue_url":"https://api.github.com/repos/ngocchung/android-api23/issues/1","id":134510509,"user":{"login":"smarek","id":384824,"avatar_url":"https://avatars.githubusercontent.com/u/384824?v=3","gravatar_id":"","url":"https://api.github.com/users/smarek","html_url":"https://github.com/smarek","followers_url":"https://api.github.com/users/smarek/followers","following_url":"https://api.github.com/users/smarek/following{/other_user}","gists_url":"https://api.github.com/users/smarek/gists{/gist_id}","starred_url":"https://api.github.com/users/smarek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarek/subscriptions","organizations_url":"https://api.github.com/users/smarek/orgs","repos_url":"https://api.github.com/users/smarek/repos","events_url":"https://api.github.com/users/smarek/events{/privacy}","received_events_url":"https://api.github.com/users/smarek/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T07:31:58Z","updated_at":"2015-08-25T07:31:58Z","body":"As I said `I guess Gradle doesn't check JAR dependencies for compatibility issues.` which means JAR is not solving the issue.\r\n\r\nIf you run my code (sample HttpGet from Google) with JARs it crashes too."}}