Android Studio中的Android项目结构不正确;只有一个build.gradle文件

时间:2016-12-16 05:13:25

标签: android-studio android-gradle build.gradle

我正在使用Android Studio,我正在尝试将FireBase集成到我的应用程序中。为此,我需要在项目的根build.gradle和模块的build.gradle中添加依赖项。但我知道我的项目中只有一个build.gradle。当我在同一个build.gradle中添加所有内容(FireBase的依赖项)时,它无法正常工作。

所以我明白它与build.gradle有关。 Here's the project structure screenshot 。可能这个项目是从eclipse导入的。有没有办法我可以有2个build.gradle文件而无需再次创建项目?

这篇文章与Android Project Structure is incorrect; only one build.gradle有相似之处。 请不要将其标记为重复。因为在上面的链接中,答案是使用单个build.gradle。但在我的情况下,我需要2 build.gradle继续前进。由于我没有足够的声誉,我无法评论该帖子。对不起。请帮忙。

这是我唯一的build.gradle的样子:

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"
    }
}

1 个答案:

答案 0 :(得分:0)

你有两个渐变。您需要从左上角更改文件系统的视图。将其更改为&#34; android&#34;

enter image description here