我正在尝试将我的android应用程序与我本地的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
这听起来像是我必须把版本增加到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?
但我觉得我完全错了。有人知道我该怎么做。
1条答案
按热度按时间j0pj023g1#
打开
build.gradle
(模块:应用程序)在项目窗口中改变
minSdkVersion
24岁或以上