Android studio错误:错误:(23,0)无法在根项目上找到方法android()

时间:2016-08-19 19:23:20

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

我重新安装了android studio,我在另一台PC上使用与android studio相同的项目,所以代码可能很好! 这是完整的错误:

 Error:(23, 0) Could not find method android() for arguments [build_1z9k6ruj47plglocgqknjnoag$_run_closure3@133cf914] on root project 'allthingsvegan-android-9d296805dc64' of type org.gradle.api.Project.

打开文件

我在互联网上找到的解决方案包括更改代码..所以它们与我无关

谢谢! 的build.gradle:

// 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:2.2.0-beta1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

android {
    buildToolsVersion '24.0.1'
}

3 个答案:

答案 0 :(得分:2)

这是顶级 $scope.selectedCat = []; $scope.selectedCl = []; $scope.updateCategory = function (categoryId) { if ($scope.selectedCat.indexOf(categoryId) > -1) { $scope.selectedCat.splice($scope.selectedCat.indexOf(categoryId), 1); } else { $scope.selectedCat.push(categoryId); } $scope.queryCategory = 'categoryId=in=(' + $scope.selectedCat + ")" // console.log($scope.queryCategory) //Optional, to reload on change. $scope.requestSelected ($scope.queryCategory) }; $scope.updateClass = function (classId) { if ($scope.selectedCl.indexOf(classId) > -1) { $scope.selectedCl.splice($scope.selectedCl.indexOf(classId), 1); } else { $scope.selectedCl.push(classId); } $scope.queryClass = 'eventClassId=in=(' + $scope.selectedCl + ")" // console.log($scope.queryClass) //Optional, to reload on change. $scope.requestSelected ($scope.queryClass) }; $scope.filter = [] var string; $scope.requestSelected = function (param){ if($scope.filter already has an elem with the same letters as param){ // delete this elem then $scope.filter.push(param) } else { $scope.filter.push(param) } // final result string = $scope.filter.join(";") console.log(string) } 文件 在此文件中,您无法使用此块:

import sklearn

删除此块。

答案 1 :(得分:1)

你需要应用android插件:

 apply plugin: 'com.android.application'

这需要在像这样的buildcript之后完成:

// 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:2.2.0-beta1'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

apply plugin: 'com.android.application'

android {
    buildToolsVersion '24.0.1'
}

答案 2 :(得分:0)

  • 取消注释 build.gradle(Project:android-start)中的android标记 enter image description here
  • 重建它要求更新的gradle。
  • 更新gradle然后同步它