jhy / jsoup

jsoup: the Java HTML parser, built for HTML editing, cleaning, scraping, and XSS safety.
https://jsoup.org
MIT License
10.91k stars 2.18k forks source link

IOException on get with Android 9 (API 28) [NOT A BUG] #1153

Closed MS893 closed 5 years ago

MS893 commented 5 years ago

I perform a Jsoup get request Document doc = Jsoup.connect(url).timeout(25000).get();

I use 1.11.3 version of Jsoup implementation 'org.jsoup:jsoup:1.11.3'

When I compile using API 27, it's working fine and return the document with html. compileSdkVersion 27 (minSdkVersion 14 and targetSdkVersion 27)

When I compile using API 28, I have got an IOException when executing the get. compileSdkVersion 28 (minSdkVersion 14 and targetSdkVersion 28)

My other dependencies

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
implementation 'com.scottyab:aescrypt:0.0.1'
implementation 'com.github.Yalantis:Context-Menu.Android:1.0.8'
implementation 'com.github.GrenderG:Toasty:1.3.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.4'
// for these librairies, I change 28.0.0 by 27.0.0 when using API27
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:preference-v14:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true
}
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.android.gms:play-services-drive:16.0.0'
MS893 commented 5 years ago

I add the detail of the IOException "Cleartext HTTP traffic to URL not permitted"

MS893 commented 5 years ago

SORRY, this is not a bug from Jsoup, just the API 28 which change the cleartext disabled by default.

https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted

https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted

https://medium.com/@son.rommer/fix-cleartext-traffic-error-in-android-9-pie-2f4e9e2235e6