I just installed android studio and updated the sdk. I created a new project, but it seems not to compile. There is a problem with gradle sync:
Error:(29, 0) Could not find method android() for arguments [build_st17khxxb7irr63f8isja72t$_run_closure4@3d9ba855] on root project 'MyApplication' of type org.gradle.api.Project.
This is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Some useless words because too much code
This is the build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
ext {
compileSdkVersion = 22
buildToolsVersion = '25.0.1'
}
}
android{
compileSdkVersion 22
buildToolsVersion '25.0.1'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
As I understand you are talking about a gradle build problem. If I understand it right, there is an easy fix.
Paste in this code below it:
compileSdkVersion 24 buildToolsVersion "23.0.3
It should look like this then:
android { compileSdkVersion 24 buildToolsVersion "23.0.3"
Could not find method android() for arguments in Android Studio project
This link will help you to solve your build.gradle problem.
apply plugin: 'com.android.application'
android { compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "com.example.myapplication" minSdkVersion 16 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' } } }
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })
compile 'com.android.support:appcompat-v7:25.0.1' testCompile 'junit:junit:4.12' }
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.