最近我迁移到了基于IntelliJ的新版Android Studio IDE
我遵循的指南如下:
https://developers.google.com/maps/documentation/android/start(基础知识)
How can I create an Android application in Android Studio that uses the Google Maps Api v2?(导入所需的Google Play服务和支持库到Android Studio中)
所有库都被Android Studio正确检测到,我没有收到任何“库未找到错误”。该项目没有显示任何错误。但是,当我尝试编译它时,我得到了这个错误。
Gradle:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':AID-AmritaInfoDesk:compileDebug'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
这是我的 explorer.java 文件。
package com.aid.explorer;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class explorer extends FragmentActivity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.explorer);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}
}
这是我的 explorer.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
我想知道出了什么问题。任何帮助都将不胜感激。