I'm using Android Studio and I'm trying to integrate FireBase in my application. For that, I need to add dependencies in both project's root build.gradle and module's build.gradle. But I understand that there's only one build.gradle in my project. When I added everything (dependencies for FireBase) in the same build.gradle, it wasn't working.
So I understood it has something to do with build.gradle. Here's the project structure screenshot .Probably the project was imported from eclipse. Is there any way I can have 2 build.gradle files without creating the project again?
This post has similarity with Android Project Structure is incorrect; only one build.gradle. Please dont mark it as duplicate. Because in the above link, the answer was to go with a single build.gradle. But in my case I need 2 build.gradle to proceed further. Since I don't have enough reputation, i couldn't comment on that post. Sorry.Please help.
here's how my only build.gradle looks like :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
//FireBase dependency
//classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
//FireBase dependency
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
}
//FireBase
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion '23.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
arm {
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
minSdkVersion 19
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
defaultConfig {
minSdkVersion 19
applicationId "com.nytshift.eym.pas"
}
}