虚拟机登陆本地数据库出现的问题:
(1)编译运行时常出现:
Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
这时候要在这里添加:
compileOptions{
sourceCompatibility org.gradle.api.JavaVersion.VERSION_1_8
targetCompatibility org.gradle.api.JavaVersion.VERSION_1_8
}
1.8、1.7都可以看自己版本;
(2)添加完编译后后发现一个问题:
Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.
c
jackOptions {
enabled true
}
然后编译就过了。
(3)运行虚拟机时显示错误:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
这时候要在这里添加:
注意如果是虚拟机的话地址一定要为 10.0.2.2 (127.0.0.1不行,会链接失败)
修改后就成功了!!!!!