在机器人工作室编译错误。当制作一个简单的谷歌Android地图API第2项目机器人、错误、工作室、简单

由网友(吸煙傷肺゛想妳傷心)分享简介:最近我迁移到新的 Android的Studio IDE中基于的IntelliJ Recently I migrated to the New Android Studio IDE based on IntelliJ该指南我也跟着为:https://developers.google.com/maps/documen...

最近我迁移到新的 Android的Studio IDE中基于的IntelliJ

Recently I migrated to the New Android Studio IDE based on IntelliJ

该指南我也跟着为:

https://developers.google.com/maps/documentation/android /启动(的 基础知识的)

https://developers.google.com/maps/documentation/android/start (for basics)

How我可以建立在Android的Studio中使用谷歌地图API第2版Android应用程序? (导入所需的谷歌播放服务和支持 库到机器人工作室的)

How can I create an Android application in Android Studio that uses the Google Maps Api v2? (for importing the required Google Play services and support libraries into android studio)

所有的库进行了适当的搭载Android工作室检测,我没有得到任何​​库未发现的错误。该项目被证明无差错。然后,当我试图编译它,我得到这个错误。

All the libraries were properly detected by Android Studio and i didn't get any 'library not found errors'. The project was shown error free. Then when i tried to compile it i got this error.

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"/>

我想知道哪里出了问题。任何帮助将是大大的pciated AP $ P $

I would like to know what went wrong. any help would be greatly appreciated

推荐答案

我是按照相同的指令,除了我创建一个新的项目。在项目结构我去掉了Android的摇篮方面,是能够建立成功。可选可以更新摇篮建立文件和Android的摇篮面添加到播放服务库。

I was following the same instructions except I was creating a new project. Under the project structure I removed the Android-Gradle facet and was able to build successfully. Optionally one can update the gradle build files and add the Android-Gradle facet to the play services library.

注:我改变谷歌的名称,播放服务目录

NOTE: I changed the name of Google Play Services directory.

build.gradle 针对谷歌播放服务库。

build.gradle for Google Play Services library.

apply plugin: 'android-library'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('google-play-services.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion '17.0.0'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aild.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

build.gradle 测试应用程序。

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(':lib-google-play-services')
    compile files('../lib-google-play-services/libs/google-play-services.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 16
    }
}
阅读全文

相关推荐

最新文章