我正在尝试连接我的安卓应用程序与我的本地MySQL数据库,然后获得一些内容的数据库与JDBC。因此,我尝试使用以下代码连接到数据库:
try{
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/rpg","root", "whatever");
Statement statement = connection.createStatement();
final ResultSet resultSet = statement.executeQuery("select * from player");
Log.i("Content",resultSet.getString(0));
}catch (Exception e) {
e.printStackTrace();
}我在清单中给了互联网权限(<uses-permission android:name="android.permission.INTERNET"/>)
并将mySQL连接器实现为库(mysql- connector -java-8.0.12.jar)。
当我想要启动它时,我得到了这个错误:
Default interface methods are only supported starting with Android N (--min-api 24): void com.mysql.cj.protocol.AuthenticationPlugin.destroy()
Default interface methods are only supported starting with Android N (--min-api 24): void com.mysql.cj.protocol.MessageSender.send(com.mysql.cj.protocol.Message)
Default interface methods are only supported starting with Android N (--min-api 24): byte com.mysql.cj.protocol.MessageReader.getMessageSequence()
Default interface methods are only supported starting with Android N (--min-api 24): com.mysql.cj.result.Row com.mysql.cj.result.RowList.get(int)
Default interface methods are only supported starting with Android N (--min-api 24): com.mysql.cj.protocol.Message com.mysql.cj.interceptors.QueryInterceptor.postProcess(com.mysql.cj.protocol.Message, com.mysql.cj.protocol.Message)
null
com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Alexander\Desktop\Programmierung\Testing2\app\libs\mysql-connector-java-8.0.12.jar
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
com.android.tools.r8.utils.AbortException这听起来像是我必须将minSdkVersion增加到24,对吧?所以我这样做了,然后出现了这个错误:
Invoke-customs are only supported starting with Android O (--min-api 26)
null
com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Alexander\Desktop\Programmierung\Testing2\app\libs\mysql-connector-java-8.0.12.jar
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
com.android.tools.r8.utils.AbortException 所以我也把它增加到26,然后得到这个错误:
Installation failed with message INSTALL_FAILED_OLDER_SDK: Failed parse during installPackageLI: /data/app/vmdl127069021.tmp/base.apk (at Binary XML file line #7): Requires newer sdk version #26 (current version is #25).
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?但不管怎么说,我觉得我的方式是完全错误的。有人知道我该怎么做了。
发布于 2019-06-13 02:09:54
build.gradle (模块:应用程序)minSdkVersion更改为24或更高版本https://stackoverflow.com/questions/52468091
复制相似问题