当我将mysql-connector-java:8.0.11.jar导入Android项目时发生错误

时间:2018-06-12 11:23:00

标签: java android mysql

我是新来的,不是真的如何正确使用编辑器,如果这给你带来麻烦,我真的很抱歉。

我知道通过JDBC连接到MYSQL服务器是不安全的,但我正在学习,经过几天的搜索和尝试,我真的无法克服它自己:d。

问题是,没有JDBC,项目运行良好。起初我使用rmysql-connector-java-5.1.46.jar。没有错误,整个程序运行顺利,但我无法连接到MYSQL。我确信环境设置正确,我可以ping和telnet服务器的IP。它说Connection已建立。那时的例外情况如下: 无法创建与数据库服务器的连接。

经过很长时间确认我的URL,端口,用户和密码都正确无误后,我听说这可能是因为我使用的是错误的JDBC版本,所以我为MYSQL下载了一个较新的JDBC,并删除了旧的一。将jar导入libs后出了问题 - 我现在甚至无法启动项目。

错误日志如下:

com.example.administrator.projectapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.administrator.projectapp, PID: 21249
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.administrator.projectapp/com.example.administrator.projectapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.administrator.projectapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/base.apk", 
......],
nativeLibraryDirectories=[/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
.....
06-12 10:53:06.861 21249-21249/com.example.administrator.projectapp E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.administrator.projectapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/base.apk",
...,
nativeLibraryDirectories=[/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
  ... ...more              
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
 at java.lang.VMClassLoader.findLoadedClass(Native Method)
... ... more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/base.apk", zip file "/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_slice_0_apk.apk", 
...],
nativeLibraryDirectories=[/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93
                    ... ... more
06-12 10:53:06.862 21249-21249/com.example.administrator.projectapp E/AndroidRuntime:       Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_dependencies_apk.apk because: Failure to verify dex file '/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_dependencies_apk.apk': Bad method handle type 7
at dalvik.system.DexFile.openDexFileNative(Native Method)
... ... more
[CIRCULAR REFERENCE:java.io.IOException: Failed to open dex files from /data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_dependencies_apk.apk because: Failure to verify dex file '/data/app/com.example.administrator.projectapp-EgKWaNSakZUfFs2VVceuPw==/split_lib_dependencies_apk.apk': Bad method handle type 7]

点击进入应用程序后,崩溃只需不到半秒钟,系统告诉我“ProjectApp已停止”

我真的很期待UR的所有帮助。谢谢。

0 个答案:

没有答案