Android Studio 2.3, cannot build gradle. Error 304 [duplicate] - android

This question already has answers here:
Why am I getting "(304) Not Modified" error on some links when using HttpWebRequest?
(5 answers)
Closed 5 years ago.
I am just installed Android Studio 2.3.
However, when I create any application, it always error.
For example, I just create new blank project.
It shows error: Error:Response 304: Not Modified has no content!
(see the screenshot)
I have already tried
Installing and reinstalling android studio, even delete the folder and not importing anything.
Invalidate cache and restart Android Studio
UPDATE:
I have already fixed this...
The problem is jcenter might now have the junit.jar or espresso.jar needed (or my internet connectin prevent me to fecth those). So, I change it to mavenCentral and it works
Before:
allprojects {
repositories {
jcenter()
}
}
After:
allprojects {
repositories {
mavenCentral()
}
}

I've been struggling with the same thing for many hours
https://services.gradle.org/distributions/gradle-3.3-all.zip download this link and extract it into C:\Program Files\Android\Android Studio\gradle\ now go to androidstudio -> setting -> build -> gradle edit gradle home as C:\Program Files\Android\Android Studio\gradle\gradle-3.3 disable offline work and save it
If it is not work diable testCompile 'junit:junit:4.12' in gradle and retry this process

Related

how to fix aapt2 error in android Studio 4.1.1?

few days ago i deleted the whole gradle file and installed it again manually
introduced its path to android studio 4.1.1 and created a project to test
fortunately gradle worked fine but when i tried to run app on emulator a red goddamn error appears that doesn't let me sleep for 3 days
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
> Could not find aapt2-4.1.1-6503028-linux.jar (com.android.tools.build:aapt2:4.1.1-6503028).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/4.1.1-6503028/aapt2-4.1.1-6503028-linux.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
i read the documentation and i guess that was outdated or just couldn't solve my problem
cause i declared repository and nothing made a difference.
every solution i found belongs to 2 or 3 years ago and most of em say the same
add google() to your repositories in build.gradle
and they were right
that should made the problem solved but in 3 years ago.
now by default android studio has google() in repositories
and still i see the goddamn red error on my screen
in error obviously points to missing a file named aapt2-4.1.1-6503028-linux.jar and thanks to google ,it gives me the download link
i downloaded the file but i don't know where to put it.
as the error says ,
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
so anybody knows a path for this file or what ever it is ?!
make an old noob programmer HAPPY ;(
Hi sorry for the late answer ,may be this will use to others
Add Maven to your project build.gradle app it will solve
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
I had a similar issue. This solved it for me, but I don't know why. Under my Project build.gradle I changed the classpath in my dependencies to a lower version. I had it set as 4.1.1 but changed it to 3.1.4. I then clicked Sync Now.
I still cannot get my emulator to run, but this got rid of the error.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tolls.build.gradle:3.1.4" //was 4.1.1
}
}
After many hours messing with Gradle repository config, etc. This solved the problem:
In Android Studio, go to {File} menu > {Invalidate Caches and Restart},
Then Sync your gradle/project.
It seems that some older files/packages are becoming idiotic when you update your IDE.
p.s I also did {Help} > {Check for IDE updates} and there were updates for Emulator and stuff. It still didn't work, until i used the "Invalidate Caches" option.

Gradle project sync failed. Unresolved dependencies

I downloaded my repository through git on a new computer, cloned everything, but when I ran a Gradle sync it failed with this error message:
I tried cleaning the project, invalidating caches / restart, redownload the whole repository, delete Gradle file and get it back from the repository. Nothing helped. Funny thing is, the guys at the office are building without a problem from the same Gradle file. Any idea what I'm doing wrong here? Btw, I checked all the 20+ threads here on SO with similar titles, but none of them described the same problem I'm having. However, I tried all the fixes suggested there, but that didn't show any results either.
After wasting a whole day on this I found out the core of the problem.It was a problem with Gradle. The links for these four dependencies pointed to pages, which returned 404, therefor Android Studio couldn't get the dependencies and threw this error. My temporary decision is to use a different Gradle version, in which the links point to the right pages.
Add google() in your app build.gradle.
1. buildscript {
repositories {
google()
jcenter()
.....
}
}
2. allprojects {
repositories {
google()
jcenter()
.....
}
}
Then try to build.
Open SDK manager and choose the target SDK version then click ok , it will start installing the version directly.enter image description here
Open File > Project Structure in window select versions as my.
After that sync gradle
resolve for me

Gradle build unable to compile when trying to add ads [duplicate]

This question already has answers here:
Failed to resolve: com.google.firebase:firebase-core:11.2.0
(6 answers)
Closed 5 years ago.
Ok so I am trying to add ads to my application and it tells me to add this line of code in my build.gradle file.
Error image:
compile 'com.google.android.gms:play-services:11.2.0'
As you can see in this image at the bottom it says
Failed to resolve:compile 'com.google.android.gms:play-services:11.2.0'
I cannot click Install repository and sync project because when I do it does nothing. Does not even open another windows or anything?
try adding
maven { url 'https://maven.google.com' }
to your project level gradle file
Try doing these steps,
1)Either you are missing maven link
`repositories {
maven {
url "https://maven.google.com"
}
}`
2) Try updating to your google repository in Android SDK
Start Android Studio -> On the Tools menu, click Android > SDK Manager.
Update the Android Studio SDK Manager: click SDK Tools, expand Support
Repository, select Google Repository, and then click OK.

Gradle build hangs after update to Android Studio 1.3

I've just updated to Android Studio 1.3, opened an existing project I was working on, tried to run it. Gradle just gets stuck at the "Resolve dependencies':app_debugCompile'", I tried to wait, I waited for over an hour and nothing happened.
How can I solve it to get my app running?
If you are using proxy, it seems https proxy server setting is not correctly done in Android studio 1.3.
You can set https proxy server manually in gradle.properties,
systemProp.https.proxyHost=proxy.server.address
systemProp.https.proxyPort=8080
see Gradle Sync fails in Android studio 1.3 and gradle behind proxy in Android Studio 1.3.
How can I solve it to get my app running?
Start by identifying the problem more precisely. To do so, run gradle from the command line in the root directory of your project :
./gradlew --debug clean build
The --debug argument will simply enable the debug log level and hopefully providing useful information to understand where/why it is hanging.
I face this problem in linux and my problem solved after installing these dependencies on fedora :
sudo dnf install glibc.i686 zlib.i686 libstdc++-devel.i686
I had this problem.Just see this page. Solution is here
Solution :
Make sure you have latest stable version ( current 2.0.0 )
Make sure your gradle version is 2.0.0 in build.gradle ( classpath 'com.android.tools.build:gradle:2.0.0')
Final step and most important one is change your jcenter() to mavenCentral()
So you can easily add new dependency and sync project under 3sec !
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Go to app > Right Click on it > Open Module Settings>Change build tool version to 22.0.1
Try again after restarting your Android Studio
I've just encountered this issue in the OP, in my case it was taking over 20min just to get gradle build going. Getting stuck at the "Resolve dependencies':app_debugCompile'" as well.
I'm still relatively new to Stackoverflow so I can't up-vote yet. But what I can tell you is that if your behind a web proxy like I am and you've just updated to Android 1.3.1 you will probably notice this issue immediately. I already had my companies web proxy in the IDE settngs and yes there is something not ok with the 1.3.1 update. As corochann posted you have to add the proxy info to the gradle.properties of your project. Once I actually did this I noticed the difference immediately. Going forward until its resolved you'll probably have to add this to each project if your behind a web proxy and running 1.3.1. I have another machine at home that isn't behind a proxy and is running Android Studio version before 1.3.0 and had no issues. Hope this helps!!

Android Studio installation doesn't work with gradle

I am absolute beginner with Android Studio (especially Gradle) and having big trouble getting Android Studio to work. I downloaded and installed the most recent version of Android Studio (0.8.0). I have set the JDK_HOME variable. However, after I create a new project, I always receive the following message:
Error:Unknown host 'jcenter.bintray.com'.
Enable Gradle 'offline mode' and sync project.
Learn about configuring HTTP proxies in Gradle
If I try to compile the project, I get the following message dialog:
After reading a post, I manually downloaded the Gradle binaries (latest, 2.0), extracted it onto the local drive, went to Settings and set the Gradle path to the respective directory using the following:
I also tweaked the build.gradle file under the project to point to the latest Gradle 2.0 version. However, now I get the following error message:
Error:A problem occurred configuring root project 'HelloAndroidStudio'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:2.0.+.
Required by:
:HelloAndroidStudio:unspecified
Failed to list versions for com.android.tools.build:gradle.
Unable to load Maven meta-data from http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml.
Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml'.
jcenter.bintray.com
Please can someone help. Being my first time with Gradle, I have been trying for so many days without any clue to the problem. Thanks.
Change the Gradle version to lower ones and restart the Android Studio, you may get it.
Add this in build.gradle
classpath 'com.android.tools.build:gradle:1.1.0'
Setting the http_proxy under appearance & behaviour -> system settings -> http proxy has solved the problem
Change to the latest classpath in the dependencies.
For AS 1.5.1 I will do like this :
buildscript {
repositories {
jcenter()
}
dependencies {
**classpath 'com.android.tools.build:gradle:1.5.0'**
}
}

Categories

Resources