public static Retrofit getRetrofit() {
return new Retrofit.Builder()
.baseUrl("localhost:8888")
.addConverterFactory(GsonConverterFactory.create())
.client(RetrofitApi.getOkHttpClient())
.build();
}
I chased the library I think here is where the null return.
HttpUrl parse(HttpUrl base, String input) {
int pos = skipLeadingAsciiWhitespace(input, 0, input.length());
int limit = skipTrailingAsciiWhitespace(input, pos, input.length());
// Scheme.
int schemeDelimiterOffset = schemeDelimiterOffset(input, pos, limit);
if (schemeDelimiterOffset != -1) {
if (input.regionMatches(true, pos, "https:", 0, 6)) {
this.scheme = "https";
pos += "https:".length();
} else if (input.regionMatches(true, pos, "http:", 0, 5)) {
this.scheme = "http";
pos += "http:".length();
} else {
return null; // Not an HTTP scheme.
}
} else if (base != null) {
this.scheme = base.scheme;
} else {
return null; // No scheme.
}
12-26 17:57:40.902 2225-2303/io.softape.erhuo E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: io.softape.erhuo, PID: 2225
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: Illegal URL: localhost:8888
at retrofit.Retrofit$Builder.baseUrl(Retrofit.java:304)
at io.softape.erhuo.api.retrofit.util.RetrofitApi.getRetrofit(RetrofitApi.java:41)
at io.softape.erhuo.api.retrofit.util.RetrofitApi.<init>(RetrofitApi.java:36)
at io.softape.erhuo.api.asycnTask.NetworkGetPostTaskWithEndpoint.doInBackground(NetworkGetPostTaskWithEndpoint.java:46)
at io.softape.erhuo.api.asycnTask.NetworkGetPostTaskWithEndpoint.doInBackground(NetworkGetPostTaskWithEndpoint.java:26)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)聽
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)聽
at java.lang.Thread.run(Thread.java:818)聽
Here is the exception.
Try adding http:// as a prefix, like http://localhost:8888/.
Most helpful comment
Try adding
http://as a prefix, likehttp://localhost:8888/.