Skip to content Skip to sidebar Skip to footer

Android Jdbc Connection Results In Ctahttp Exception

Im currently trying to establish a connection from my Android app to a MySQL server running on my raspberry pi. I added the library to android studio correctly by adding it's into

Solution 1:

CTA = China Type Approval, this is something that Mediatek adds in Android for testing purpose.

Your error is happening in DriverManager.getConnection() that probably uses okhttp, apache-http or Socket class in Android's libcore to do its requests.

Mediatek patched these libraries for adding a control of HTTP requests. It tries to load dynamically some methods defined in /system/framework/mediatek-cta.jar but it is probably absent or not accessible on your android device's file system.

I see 5 solutions :

  1. Add an appropriate mediatek-cta.jar via OTA or via adb remount if you are on a custom/rooted ROM
  2. Use another device with the same application's source code (a non- Mediatek based device would not have that issue).
  3. Upgrading your OS via an official OTA update and hope device manufacturer fixed the issue.
  4. Rebuild and customize the OS by yourself with the following modifications
    • Make sure medatek-cta is added to PRODUCT_PACKAGES and PRODUCT_BOOT_JARS
    • Remove the hooks in libcore, okhttp and apache-http.
  5. Contact your OS maintainer's support.

Solution 2:

As I encountered the same message once, I also was misled by it firstly. However, it turned out that you can not open a Socket or other network connection on the main thread (see https://developer.android.com/training/basics/network-ops/connecting#intro-net-ops). This may also be the problem in your case.

This message itself only seems to be an information for testing purposes as vhamon pointed out.

Solution 3:

add this permisions to AndroidManifest, hope will help)

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Post a Comment for "Android Jdbc Connection Results In Ctahttp Exception"