在我的项目中包含3个子模块,这就是为什么我创建一个other.gradle
文件来获取所有依赖项和其他要求,然后将此gradle
文件添加到我的应用程序build.gradle
如果我在other.gradle
文件夹中添加了app
文件,则工作正常
以下是我的other.gradle
和build.grdale
other.gradle
dependencies {
compile 'rongi.rotate-layout:rotate-layout:3.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.google.android.gms:play-services-appindexing:8.4.0'
compile files('libs/gson-2.2.2.jar')
}
build.grdale
apply plugin: 'com.android.application'
apply from: 'extgradles/other.gradle'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.cj.myapplication"
minSdkVersion 20
targetSdkVersion 25
versionCode 1
versionName "1.0"
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
我将other.gradle
文件放在Android工作室项目解剖结构的app文件夹中的extgradles
文件夹中。
我们如何在other.gradle
?
build.gradle
我只想将我的资源other.gradle
添加到应用程序的根文件夹中,并希望在build.gradle
中访问它,如果我已将其添加到'app'文件夹中,则可以正常工作。但是如何传递路径从build.gradle
的根文件夹中,您可以看到build.gradle的第二行,即满足您的语句
答案 0 :(得分:0)
compile
之前找不到 apply plugin: 'com.android.application'
方法,因此您无法在根gradle文件中添加依赖项。