我使用 谷歌 GCM github 示例
我想在这个例子中添加一个sql连接
所以我在eclipse中写了这个尝试,这是成功的
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://ip:port/";
String user = "root";
String password = "123456";
try {
sql setting ...
}
}
catch(ClassNotFoundException e) {
System.out.println("No");
e.printStackTrace();
}
catch(SQLException e) {
e.printStackTrace();
}
但是当我在 GCM 示例中创建一个 *.java 并复制到 *.java
并将此代码添加到 bulid.gradle(Module.app)
它失败了
sourceCompatibility = 1.7
targetCompatibility = 1.7
这是错误信息
Error:Gradle: 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.
如何解决?
顺便说一句,推荐 cmd java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
原文由 Stackoverflow 发布,翻译遵循 CC BY-SA 4.0 许可协议
1- 下载 MySQL JDBC 连接器 3.0.17
要么
使用 Eclipse Java 8 支持
2- 将 INTERNET 权限添加到您的清单文件