Android Studio-Gradle清单文件路径 [英] android studio - gradle manifest file path
问题描述
我试图在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:
- 打开build.gradle(带有
android
和dependencies
元素的那个). - 在
dependencies
下添加compile 'com.android.support:support-v4:+'
- Open build.gradle (the one with the
android
anddependencies
element). - Under
dependencies
addcompile '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屋!