Could not compile Build file - android

The android project file got deleted mistakenly after I have successfully recovered from Drill Disk and tried to run the project I got an error
Build file 'E:\AndroidStudioProjects\side\app\build.gradle' line: 25
Could not compile build file 'E:\AndroidStudioProjects\side\app\build.gradle'.
> startup failed:
build file 'E:\AndroidStudioProjects\side\app\build.gradle': 25: unexpected char: 0x0 # line 25,
column 2.
}
^
I have tried pasting it from the project the Build.Gradle file from Github still I get the error:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
center()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I don't want to pull or create a new instance because I have made the changes in the old file, so if I do it again it will take a lot of time again.
So any expert please help me with what I should do, I have referred to the older post here at Stackoverflow related to this topic But I was unable to get the solution?

Related

Android Studio Could not find com.android.tools.build:gradle:4.0.1. Error

Could not find com.android.tools.build:gradle:4.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom
Required by:
project :
Open File
that is the error log.
I searched in many websites and all I got was to add google() in build.gradle file witch android studio has already done it.
I tried mavenCentral() too but that error still exist.
I installed AS 3.1 then I upgraded it to 4.0.1 which is the latest stable version.
the build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
// 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
}
Edited:
I can download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom manually but anyone knows where to copy and paste it?
I had the same problem for days and i solved that yesterday.
check my answer here :
Could not find com.android.tools.build:gradle:4.0.1 OR 4.0.0 OR any versions

:app:mergeDebugAssets > unable to create new thread when updating to Android Studio 3.0.1

I was building a project with a previous version of Android Studio and I decided to update it. So once I updated it I keep getting the same error on application Run (not on clear, not on synching grandle). The error is the following:
Error:Execution failed for task ':app:mergeDebugAssets'. > unable to create new native thread
I tried to clean and build again. I tried to change studio.vmoptions but none of them worked for me.
Here is the full build.gradle file:
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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
}
Pls update distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip in gradle-wrapper.properties file at gradle folder then rebuild your project.

Gradle project sync failed android studio version 2.2.3 ERROR

Well this is my first time using android studio and i keep getting an error message which says:
Gradle sync failed: Could not find method android() for arguments [build_43qncadg6ssgwl9025usbfvce$_run_closure3#c74f8ce] on root project 'MyApplication' of type org.gradle.api.Project.
Consult IDE log for more details
HERE IS THE CODE:
// 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.3.3'
// 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 {
compileSdkVersion 25
buildToolsVersion '25.0.3'
}
dependencies {
}
ERROR: could not find method android() for arguments.
What does this error mean? How can I solve this?
A typical Android project has a root project and a sub project containing the app. It seems you showed the build.gradle of the root project.
The android section would typically go into the sub project's build.gradle.

Exception : mergeDebugResources in Android Studio

I got following Error if I try to add dependency in Top - level build.gradle file. This dependency is very much useful to add GCM in project without it GCM won't work:
Dependency :
classpath 'com.google.gms:google-services:1.5.0-beta2'
Error :-
Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details
If I remove that dependency from top-level build.gradle the project compiles and run successfully.
If I add that file I got the error and Android Studio do not run project.
Please help me to get out of this error.
Edit
Here is my project level 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:2.0.0-alpha6'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
// 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
}
try Changing latest version of dependency from HERE:
classpath 'com.google.gms:google-services:2.0.0-beta5'
Also make sure you are setting correct Gradle plugin dependency as well in root project gradle file.
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
So, your final project build.gradle file will look like
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
}
Try this it should help.
buildTypes {
release {
multiDexEnabled true;
}
}
in your Gradle log, if you're getting bad/invalid PNG file then take a look at my answer at Android Studio Gradle 2.0.0-alpha1 build errors
Hope this helps...

Why can't I really follow this Android Studio tutorial?

I am following this tutorial on how to use Android Studio to create android apps. At the very end, the user opens the file 'build.gradle' which looks completely different from what I have:
// 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.3.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
}
Maybe this is not very important? Or is the video using an old version of AndroidStudio/SDK/gradle/whatever?
You are opening the top-level gradle file. The gradle file that appears in the video is the app module one.
You can have more than one module in the same project to divide your app code and/or to create different apps that share some code. Each module has its own gradle file to configure its dependencies and know how to compile it. The top-level file contains common configuration options for all modules, as the top comment tells.

Categories

Resources