Android Question okHTTP, okHttpUtils, etc

crimson ghost

Member
Licensed User
Longtime User
I have a project that was gine a few months ago. I am now having problems just reopening it.

B4A version: 5.20
Parsing code. Error
Error parsing program.
Error description: Unknown type: okhttpclient
Are you missing a library reference?
Occurred on line: 8 (HttpUtils2Service)
Private hc As OkHttpClient

I also get okhttresponse and okhttpclient are unknow types.

Could someone tell me what http libraries, code, whatever I need to use in order to get rid of this. If you do provide such information, would you please include appropriate links to where I can get these things. I have been trying to find okHTTP to replace HTTP (I think I might need it from what I have read) but all I could find was a jar file but no xml.

I have included HttpJob and HttpUtils2Service.

Thanks for the quick response. What is confusing is that the program uses the ok... stuff and the program used to be fine. It's installed and running. I have done other programs since then so I must have done something without realizing what I was doing.

I don't have any of the files you mentioned:
OkHttp.jar
OkHttp.xml
OkHttpUtils2.jar
OkHttpUtils2.xml
So if you could send them or point me to where I can download them (I spent several hours trying to find these things but had no luck. But, like I said, the program is installed and working fine and now it won't compile. Very confusing.

Thanks for all the responses. Let me start over. I have a program that I did nothing with for several months. I returned to that program and when I opened it and tried to run it I got several messages that libraries were missing. I included what I thought were the missing libraries and apparently did something wrong. Initial errors mentioned things with http in them as well as flingablewebview (ajwebkit fixed those). That is how I ended up where I did. Just now I went back and took out all the http libraries and added in HTTP and HttpUtils2r. I now get:
B4A version: 5.20
Parsing code. (0.45s)
Compiling code. (0.45s)
Compiling layouts code. (0.00s)
Generating R file. (0.09s)
Compiling generated Java code. (4.30s)
Convert byte code - optimized dex. Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/net/http/SslError;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/ConsoleMessage;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultJavascriptInterface;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultWebChromeClient;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultWebChromeClient$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultWebChromeClient$1$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultWebViewClient;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/DefaultWebViewClient$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Luk/co/martinpearman/b4a/webkit/FindListener;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:613)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:605)
... 4 more

I am clueless about this. I have a number of other programs that all work fine (I just checked them). Questions:
Why did this one come up and say libraries were missing?
And what happened to ajwebkit? I had to download it again.
And, of course, how do I track down the above error?

Thanks to anyone for reading this.

I decided to rebuild from scratch. I now get the above error when I add in webviewextras2 (version 2.20). Is this a coincidence or does it mean something? I guess coincidence since I still get the same error when I remove all references to it. CORRECTION. I forgot to remove it from the list of included libraries. when I did that the error stuff went away. So?

I tried replacing my files with a new download and still get the error.

Don't know if this is relevant but I and using:
C:\android-studio\sdk\platforms\android-26\android.jar
C:\Program Files\Java\jdk1.8.0_131\bin\javac.exe


Version number is 2.20. The date is 10/23/2015. Does this mean it is not the current one? If it is not current, please provide a link.

I also tried using C:\android-studio\sdk\platforms\android-19\android.jar but this also had no effect.

OK. There is conflict with ajwebkit but not with fligablewebview. But ajwebkit is used in numerous places.

Well the problem goes away if I don't use extras2. But it is still not the way it was. But I can deal with that. Thanks to anyone who took the time to read through this mess.
 
Last edited:

Didier9

Well-Known Member
Licensed User
Longtime User
It looks like okHttp is included with the distribution (the files are dated the same as the other libraries on my machine).
I have:
OkHttp.jar
OkHttp.xml
OkHttpUtils2.jar
OkHttpUtils2.xml

I also have
okhttp-2.4.0.jar
but no corresponding xml file, not sure if I actually use it...

I can send you the files I have but check that it is not already there first.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
You should never distribute any file that was included in the installation unless it was explicitly written that you are allowed to.
I suspected that much, which is why I asked him to check, but thanks for the reminder.

On this PC, I originally did not think of keeping the downloaded libraries separate from those under the Program Files folder, so I placed a number of additional libraries there and now I cannot readily tell those that came with the distribution and those that I downloaded other than by looking at the date.

I have since found that it is easy to keep them separate and point the IDE to the secondary location in Tools->Configure Path so the libraries I download now are placed under the Document folder, but I still do not know for sure which came with the distribution and those I have added.
 
Upvote 0
Top