包括谷歌地图时的编译器设置

包括谷歌地图时的编译器设置

本文介绍了Android Studio:包括谷歌地图时的编译器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Android Studio 中创建了一个新项目并添加了一个 Google 地图活动.

I created a new project in Android Studio and added a Google Maps activity.

我收到这些警告:

warning: com/google/android/gms/maps/GoogleMap.class(com/google/android/gms/maps:GoogleMap.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/google/android/gms/maps/SupportMapFragment.class(com/google/android/gms/maps:SupportMapFragment.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/google/android/gms/maps/model/LatLng.class(com/google/android/gms/maps/model:LatLng.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/google/android/gms/maps/model/MarkerOptions.class(com/google/android/gms/maps/model:MarkerOptions.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: com/google/android/gms/maps/model/Marker.class(com/google/android/gms/maps/model:Marker.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.

我的猜测是我有一个 JDK 不匹配或其他问题.我安装了 JDK 7,当我执行 javac -version 时,我看到 1.7.0_65.我在 Android Studio 的首选项中更改了项目字节码版本,但这并没有改变这些警告.

My guess is that I have a JDK miss-match or something. I installed JDK 7, and when I do javac -version I see 1.7.0_65. I changed in Android Studio's preferences the Project bytecode version but that didn't change these warnings.

我的 build.gradle 有这个

My build.gradle has this

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    compile 'com.google.android.gms:play-services:5.0.77'
    compile 'com.android.support:support-v13:18.0.+'
}

我需要做什么来修复这些警告,还是应该在 Android Studio 中忽略它们?

What do I need to do to fix these warnings, or should I ignore them in Android Studio?

推荐答案

主要版本"表示 Java 版本.Java 7 = 51,Java 6 = 50.代码是为 Java 7 编写的,这是 Android 的 dex 支持的.我不确定您正在构建的内容不是为 Java 7 设置的,但这就是问题所在.项目中的 Maven 构建工作正常.我没有看到你提到的错误,它也可能与 Java 6 vs 7 有关.

"Major version" means Java version. Java 7 = 51, Java 6 = 50. The code is written for Java 7, and that is something that Android's dex supports. I am not sure what you are building with that is not set for Java 7, but that's the problem. The Maven build in the project works correctly. I don't see the error you mention, and it may be related to Java 6 vs 7 too.

这篇关于Android Studio:包括谷歌地图时的编译器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:18