My android app needs to do some work with SQL Server using JDBC, So I've added sqlljdbc42.jar file in module,
But I got error in Build - Gradle, Below is my Gradle Console :
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2400Alpha1Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72400Alpha1Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42400Alpha1Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2400Alpha1Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
AGPBI: {"kind":"SIMPLE","text":"PARSE ERROR:","position":{},"original":"PARSE ERROR:"}
AGPBI: {"kind":"SIMPLE","text":"unsupported class file version 52.0","position":{},"original":"unsupported class file version 52.0"}
AGPBI: {"kind":"SIMPLE","text":"...while parsing com/microsoft/sqlserver/jdbc/ActivityCorrelator.class","position":{},"original":"...while parsing com/microsoft/sqlserver/jdbc/ActivityCorrelator.class"}
AGPBI: {"kind":"SIMPLE","text":"1 error; aborting","position":{},"original":"1 error; aborting"}
BUILD FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
and in Gradle Build windows I got This :
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1
Connections String is working fine and My MainActivity.java file contains :
public class MainActivity extends ActionBarActivity {
TextView tv;
Connection DbConn;
Statement stmt;
ResultSet reset;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv = (TextView) findViewById(R.id.textView);
try {
Log.e("Inside the Try Block", "Pre - Done");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
DbConn = DriverManager.getConnection("{connection string}");
Log.e("Connection","open");
stmt = DbConn.createStatement();
reset = stmt.executeQuery(" select * from Members");
tv.setText("User Name : "+reset.getString(1)+", Name : "+reset.getString(2));
DbConn.close();
} catch(Exception e) {
Log.e("Error connection", "" + e.getMessage());
e.printStackTrace();
}
}
}