Hi.
I have been trying to access from Android Studio 1.5.1 a remote MySQL server version 5.5.45-cll-lve, using MySQL Connector/J mysql-connector-java-5.1.38-bin.jar, but first, I'll have to make sure the app can even find the driver!
I downloaded the .jar from MySQL and dropped it into app/libs, relying on the app/src/build.gradle to implement it, like this:
Then, I sync-ed the gradle with the project, I figured the dependencies in build.gradle will pull it into the project:
This is my minimalist MainActivity.java for testing whether A/S can find the JDBC driver:
But when I try to run the app, it threw these errors almost immediately:
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
The error message leads me to believe it might be a version incompatibility here between jdk1.7.0 and the Connector/J.
I am at a lost over this, can anyone help with this?
SOrry, I can't seem to post .jpg
I have been trying to access from Android Studio 1.5.1 a remote MySQL server version 5.5.45-cll-lve, using MySQL Connector/J mysql-connector-java-5.1.38-bin.jar, but first, I'll have to make sure the app can even find the driver!
I downloaded the .jar from MySQL and dropped it into app/libs, relying on the app/src/build.gradle to implement it, like this:
Then, I sync-ed the gradle with the project, I figured the dependencies in build.gradle will pull it into the project:
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:design:23.2.1' }
This is my minimalist MainActivity.java for testing whether A/S can find the JDBC driver:
import android.os.Bundle; import android.app.Activity; import android.util.Log; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Connection conn = null; Statement stmt = null; ResultSet rs = null; String TAG = "DEBUG:"; try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { Log.d(TAG, "Cannot find MySQL JDBC Driver!"); ex.printStackTrace(); return; } Log.d(TAG, "MySQL JDBC Driver registered\n"); } }
But when I try to run the app, it threw these errors almost immediately:
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
The error message leads me to believe it might be a version incompatibility here between jdk1.7.0 and the Connector/J.
I am at a lost over this, can anyone help with this?
SOrry, I can't seem to post .jpg