Android Studio-Gradle清单文件路径 [英] android studio - gradle manifest file path

查看:722
本文介绍了Android Studio-Gradle清单文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Android Studio中添加v4支持库.

I was trying to add the v4 support library in Android Studio.

到目前为止,我的build.gradle看起来像这样:

My build.gradle lookes like this so far :

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
  }
}

allprojects {

  apply plugin: 'android'

  android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"        
  }

  repositories {
    mavenCentral()
  }

  dependencies {
    compile 'com.android.support:support-v4:18.0.+'
  }
}

它开始给我错误(我的项目名称是DataSharing-1):

It started giving me the error (my project name is DataSharing-1):

AndroidStudioProjects/DataSharing-1/src/main/AndroidManifest.xml (No such file or directory)

我尝试在"android {"下添加以下内容:

I tried adding the following under 'android {' :

sourceSets {
        main {
            manifest.srcFile 'DataSharing-1/app/src/main/AndroidManifest.xml'
        }
    }

我收到错误消息:

DataSharing-1/app/app/src/main/AndroidManifest.xml (No such file or directory)

如果我将srcFile更改为

If I change the srcFile to

'src/main/AndroidManifest.xml'

我收到错误消息:

DataSharing-1/src/main/AndroidManifest.xml (No such file or directory)

我的文件夹结构是:

AndroidStudioProjects/DataSharing-1/app/src/main/AndroidManifest.xml

有人可以建议如何解决此问题吗?

Can someone suggest on how to resolve this problem ?

推荐答案

将支持库添加到项目中的最佳方法:

The best way to add the support library to your project:

  1. 打开build.gradle(带有androiddependencies元素的那个).
  2. dependencies下添加compile 'com.android.support:support-v4:+'
  1. Open build.gradle (the one with the android and dependencies element).
  2. Under dependencies add compile 'com.android.support:support-v4:+'

它应该如下所示:

dependencies {
    compile 'com.android.support:support-v4:+'
    //... your previous existing dependencies after here
}

您可以将+符号替换为特定版本,但最好使用+符号,因为它可以确保您获取库的最新版本.

You can replace the + symbol with a specific version, but the + symbol is preferable since it ensures you will get the latest version of the library.

这篇关于Android Studio-Gradle清单文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆