Errors with gradle on Android Studio 0.4.6 - android-studio

Hello StackOverflow,
I have recently updated my Android Studio to the latest version (0.4.6), and I am encountering weird problems with it. When first creating my project, I got this error:
So I obviously went to my SDK Manager and updated my Build Tools to version 19.0.2. However, I still got this error message. I took a look into my build.gradle file and saw that I am missing the android paragraph, So I changed it from this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
To this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.2'
//Other Configuration
}
allprojects {
repositories {
mavenCentral()
}
}
But now I am getting this error message when trying to build (and the older Build Tools error):
I'm not sure what to do now.. How can I solve this?

As suggested by Scott keep your Root level build.gradle file like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Content of this file will be included in each module level build.gradle file at the type of Gradle sync or compilation.
Check all build.gradle files inside your modules. They all should look similar to this
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.2'
//Other Configuration
}
dependencies{
// Your all module dependencies here
}

Undo the changes you made to the top-level build file, and make those changes to the build files in your individual modules. In particular, putting an apply plugin: 'android' statement or android block in your top-level build file in that manner won't work. The error message you're seeing is happening because the build system is trying to build an Android app out of the root directory of your project, but none of the source files for such a project are there.

Related

Updated my Android Studio from 3.4.2 to 4.0,but unable to sync project due to missing of SDK 29(I have downloaded)

Error:
Could not resolve all files for configuration ':app:androidApis'.
Failed to transform android.jar to match attributes {artifactType=android-mockable-jar,
org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, returnDefaultValues=false}.
Execution failed for MockableJarTransform: C:\Users\DELL\AppData\Local\Android\Sdk\platforms\android-
29\android.jar.
Cannot create mockable android.jar
C:\Users\DELL\AppData\Local\Android\Sdk\platforms\android-29\android.jar (The system cannot find the file specified)
Build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Distribution Url
https://services.gradle.org/distributions/gradle-6.1.1-all.zip
I have tried installing and Uninstalling SDK 29 and Tools ,but same error exists.
Please Help.

build.gradle dependency results in compile error

After a long time, I have updated my Android Studio environment to the latest versions, but now my project doesn't compile anymore.
The error message displayed says
Could not find com.android.tools.build:aapt2:3.4.2-5326820. Searched
in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820.pom
- https://jcenter.bintray.com/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820-windows.jar
Required by:
project :app
The only reference there is to 3.4.2 is in build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
but if I remove this, the project doesn't compile either.
Any hint on how I can resolve this?
I had the same problem and solved it by adding google() as a repository under allprojects in the build.gradle file:
allprojects {
repositories {
google()
jcenter()
}
}

How to solve 'could not find method implemtatation()' error?

I'm working on an AndroidStudio Project, and I can't sync the project with de gradle. I have the following error :
ERROR: Could not find method implemtatation() for arguments [project ':mapwize'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I tried to change the gradle version but it didn't work.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Check the build.gradle in your modules (not the top level file).
There is a typo in the dependencies block.
You are using implemtatation instead of implementation

Gradle synchrozination Error

I am new to Android, and working in studio2.2 beta version.
My build.gradle file has following content
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {url 'http://repo1.maven.org/maven2'}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But on synchronization , Its giving the following error
Error:Could not find com.android.tools.gradle:2.0.0:.
Searched in the following locations:
file:/D:/android-studio/gradle/m2repository/com/android/tools/gradle/2.0.0//2.0.0-.pom
file:/D:/android-studio/gradle/m2repository/com/android/tools/gradle/2.0.0//2.0.0-.jar
https://jcenter.bintray.com/com/android/tools/gradle/2.0.0//2.0.0-.pom
https://jcenter.bintray.com/com/android/tools/gradle/2.0.0//2.0.0-.jar
Required by:
:MyApplication:unspecified
Any help ?
try:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.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
}
Current android gradle tool version is 2.2.0 for android studio 2.2. Also, you can now use stable release, no need for beta version
classpath 'com.android.tools.gradle:2.2.0'
Also you need gradle 2.14.1+ for this plugin.

Add maven dependency to Android Studio gradle

Just trying Android Studio & Gradle and I want to add Roboguice to my Project, this is my build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
compile 'org.roboguice:roboguice:2.0'
}
gives me
Gradle 'TestApp' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'compile()'!
I tried to move the line
compile 'org.roboguice:roboguice:2.0'
within the dependencies in buildscript but that also failed.
How is this done correctly?
dependencies {
compile 'org.roboguice:roboguice:2.0'
}
Move this part from build.gradle in root (top level build file) to build.gradle in your module

Resources