添加Google地图活动gradle构建永久性失败

时间:2015-08-04 01:57:33

标签: android google-maps android-gradle

我只是简单地尝试在Android Studio中添加Google地图活动,即。右键单击 - >新 - > Google - > Google地图活动,

完成后,应用程序尝试构建,然后在显示错误的构建过程中崩溃:

Gradle 'appname' project refresh failed

Error: exception during working with external systems

现在,src文件夹和清单文件已经消失,任何方法都包括最基本的super.onCreate显示"无法解析方法" ...

在尝试清理项目时,它会注意到:

Error:The markup in the document preceding the root element must be well-formed.
Error:Cannot read packageName from C:\.....\appanme\app\src\main\AndroidManifest.xml

build.gradle(Project:appname)文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

build.gradle(Module:app)文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.example.appname"
        minSdkVersion 14
        targetSdkVersion 22

        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    // Additional
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.squareup.picasso:picasso:2.5.1'
    compile 'com.android.support:cardview-v7:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
    compile 'com.android.support:palette-v7:22.2.0'
    compile 'com.mcxiaoke.volley:library:1.0.+'
    compile 'com.android.support:appcompat-v7:22.2.0'
}

为什么会这样?怎么解决?

更新

AndroidManifest.xml:此代码与清单合并,打破了应用

  <<<<<<< Original
...
...
</manifest>

=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <application>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/google_maps_key"/>

        <activity android:name="com.example.socialActions.RestaurantLocationActivity"
            android:label="@string/title_activity_restaurant_location">

        </activity>
    </application>

</manifest>
>>>>>>> Added

1 个答案:

答案 0 :(得分:1)

清单存在合并冲突,审核并删除&lt;&lt;&lt;&lt;零件和任何重复/过时的信息。或者,如果您在Android工作室中,您应该能够查看文件历史记录并在遇到困惑时恢复到早期版本。