简体   繁体   中英

Why Android studio build.gradle file is doesn't include android{}?

Here is my build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

I am trying to run a sample app but when I click on run I am getting errors:

/home/admin/AndroidStudioProjects/MyApplication/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-v14/values.xml
Error:(6, 21) No resource found that matches the given name: attr 'android:actionModeCopyDrawable'.
Error:(5, 21) No resource found that matches the given name: attr 'android:actionModeCutDrawable'.
Error:(7, 21) No resource found that matches the given name: attr 'android:actionModePasteDrawable'.
Error:(8, 21) No resource found that matches the given name: attr 'android:actionModeSelectAllDrawable'.
/home/admin/AndroidStudioProjects/MyApplication/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/res/values-v11/values.xml

similarly 175 total errors. Why I am getting this error. How to resolve it?

I followed this but since my build.gradle does't include android so I can't follow the steps.

A native Android Studio project will put your application code in an app module (aka, sub-project). To make that work, there are two build.gradle files:

  • The one in the project root directory, which contains the sort of thing you see in the question. You will need to modify this file when you want to upgrade your Gradle for Android plugin ( com.android.tools.build:gradle:1.0.0 ) to a newer version. If you elect to add other modules, you can use this top-level build.gradle file for setting up things that are in common across all your modules.

  • The one in the app module directory, which contains the configuration details for building that specific module. For simple one-module Android Studio projects, most of your build.gradle work will be in this build.gradle file, not the top-level one.

As CommonsWare commented in a reply above, there are two build.gradle files:

./build.gradle
./app/build.gradle --> this is the correct one

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM