0

Including mysql-connector-java-8.0.17.jar in the folder libs and setting the dependencies in gradle

...    
implementation files('libs/mysql-connector-java-8.0.17.jar')
...

i get this error

Process 'command 'C:\Program Files\Android\Android Studio\jre\bin\java.exe'' finished with non-zero exit value 1

In particoular

1)  java.lang.IllegalAccessException: no such method: com.mysql.cj.protocol.x.AsyncMessageReader.lambda$onError$0(Throwable,MessageListener)void/invokeStatic 2)    Caused by: java.lang.NoClassDefFoundError: com/google/protobuf/Message 3)   Caused by: java.lang.ClassNotFoundException: Class com.google.protobuf.Message not found

How can i solve? thank you all for the advice!

  • Possible duplicate of [Android JDBC not working: ClassNotFoundException on driver](https://stackoverflow.com/questions/7221620/android-jdbc-not-working-classnotfoundexception-on-driver) – ahooee Oct 08 '19 at 15:41
  • 1
    Unclear why you are using JDBC on Android. See: [JDBC vs Web Service for Android](https://stackoverflow.com/q/15853367/295004) – Morrison Chang Oct 08 '19 at 15:42

1 Answers1

0

The reason is MySQL driver has a dependency on protobuf library. See the compile dependency section here

Instead of adding lib from your local, use the following.

// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.17'

Leaving that aside, please use an API layer instead of JDBC on DB. You are welcome.

aksappy
  • 3,400
  • 3
  • 23
  • 49