Can't build in Android Studio 2.2.1 - android-studio-2.2

I just installed Android Studio 2.2.1 tonight.
I am using Linux Ubuntu 14.04 32 bit os
JAVA_HOME is jdk1.8.0_60. It is set as Android Studio boot JDL and that works fine.
However when I build my "hello world" project I get:
Gradle sync failed: Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2
I have been reading that this has to do with a large build.gradle file and that I should do this:
set multiDexEnabled true
But this is a minimal brand-new OOTB build.gradle file. I have done nothing to it.
Oh and my settings in
Project Structure -> Android SDK Location
is ~/Android/Sdk. In that directory I have:
ls ~/Android/Sdk/platforms/android-24/
android.jar data package.xml source.properties
android-stubs-src.jar framework.aidl sdk.properties templates
build.prop optional skins uiautomator.jar
So I am at a loss. Any help would be appreciated. Thanks!!

Related

Can't find "Sync project with Gradle files" in Android Studio running on Mac

I'm running into the error when I tried to run the existing project.
Error: "AndroidManifest.xml doesn't exist or has incorrect root tag"
I'm seeing a lot of solutions suggesting using "Sync project with Gradle files". I'm running Android Studio on my Mac and did not see that option. I do have AndroidManifest.xml file in the project but for some reason Android Studio can't find it.
I have the file under project_name > app > src > main > res.
I have Android Studio 4.1.1 and macOS Catalina 10.15.7
I also got a recommendation when I open up the Android Studio
Migrate Project to Gradle?
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
More Information about migrating to Gradle
Don't show this message again.
Not sure what to do about it. I'm pretty new to Android Studio. Thanks!

Android studio 3.6 issue : ApkProvisionException: No outputs for the main artifact of variant: debug

Unable to determine application id: com.android.tools.idea.run.ApkProvisionException: No outputs for the main artifact of variant: debug
when update to android studio 3.6 version, this issue come out, but 3.5 is ok at the same project.
And I can find the apk in the outputs/apk folder.
I have the same issue with a Cordova Project after I updated Android Studio to 3.6.1
As a workaround (at least for the first installation of the app) I use installDebug Gradle Task from Gradle Tab View -> Tasks -> Install
I also have issues with Build -> Build Apks so I use assembleRelease Gradle Task from Tasks -> build

Why Android Studio always download gradle EVEN THOUGH I set GRADLE_HOME & GRADLE_USER_HOME properly

I am on windows 10 x64.
I download newest Android Studio 2.3 (162.xxxx). And I also have gradle(gradle-3.3-all) in d:\gradle-3.3-all.
I set enviroment as follow:
GRADLE_HOME=D:\gradle-3.3-all
GRADLE_USER_HOME=C:\Users\walfud\.gradle
PATH=... %GRADLE_HOME%\bin ....
But when I open my project first time, studio try to download gradle-3.3-all...
I'm sure I have the neccessary gradle and env in studio:
What is more confused is that after Android Studio download gradle-3.3 in cache dir, all seems well untill I run gradlew in terminal..., like follow:
WTF! Is it true that AS just downloaded the gradle just now?!
Anyone know what wrong?

Android Studio - Gradle sync error on gradle-diagnostics-X.X.X.jar

I've just updated Android Studio and I can't sync my project anymore.
The event log reports:
Gradle sync failed: /Applications/Android Studio.app/Contents/gradle/gradle-X.X.X/lib/plugins/gradle-diagnostics-X.X.X.jar (No such file or directory)
To solve the Gradle sync error, open gradle-wrapper.properties file and update the Gradle wrapper distribution version from:
distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-all.zip
To:
Android Studio 3.4
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Android Studio 2.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
Android Studio 2.2 distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Android Studio 2.1 distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
Android Studio 2.0 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Android Studio 1.5 distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Android Studio 1.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
You can find the latest Gradle wrapper version visiting:
https://services.gradle.org/distributions/
EDIT:
As a side note, as #SeBsZ suggests,
the official repository of the Android Gradle plugin switched from MavenCentral to jCenter (see Bintray blog post).
Make sure your project build.gradle file contains the new repository and the new classpath:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
This is not strictly related to the question problem, but since we are already migrating to the new IDE preview it's better to make sure everything is in place.
If, like me, you are using an older project then you might still be using the maven repository. Make sure you change the repositories in your top-level build.gradle from maven() to jcenter(). Then make sure you are using the correct dependency as well: classpath 'com.android.tools.build:gradle:1.3.0-beta1' for the new 1.3 preview.
For me helped to set chmod on the .gradle directory to 777. After this whole Android studio started working correctly.
I got the same issue after updating android studio to 3.4
I resolve this updatig gradle-wrapper.properties
I had
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I leave
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
and with this To solve the Gradle sync error.
This is the weirdest thing ever and I never expected it to work but this:
distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
worked and got everything fixed (it was the '\' after https). It does make sense since that is an actual link to a file.
check your .bash_profile file and make sure your GRADLE_HOME points to a valid path, if things were working and you face this issue after android studio update, chances are your gradle got updated too.
Here is the example of my gradle home in .bash_profile:
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin
Had the same problem with a newly set up Android Studio 2.2.2, gradle wrapper 2.14.1. I loaded the project before i installed the needed android-23 library and installed java after Android Studio installation.
Error message in Android Studio 2.2.2:
Error:The specified Gradle distribution
'https://services.gradle.org/distributions/gradle-2.14.1-all.zip' does
not appear to contain a Gradle distribution.
Error message in cmd:
projectfolder> gradlew
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:34)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:25)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
When i used gradle from cmd however it worked
projectfolder> set PATH=%PATH%;C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> set GRADLE_HOME=C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> cd C:\projectfolder\
projectfolder> gradle
BUILD SUCCESSFUL
In cmd i see that the gradle versions and android sdk version were correct
C:\>set | find "JAVA_HOME"
JAVA_HOME=C:\Java\jdk1.8.0_111\
However in C:\Users\.AndroidStudio2.2\system\log\idea.log it said something else:
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
2016-11-29 16:04:10,597 [ 107684] INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre
After messing up Android Studio config files i ended up reinstalling everything in correct order (Java, Android Studio, Project) and it worked.
I got the same issue after updating my android studio to 1.5
Here is my error stack trace.
Error:A problem occurred configuring root project 'Kargo'.
java.io.FileNotFoundException: /home/adiyatmubarak/Documents/android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)
After I checked to the android studio instalation directory within gradle, my gradle was gradle-2.8 I don't know how to setup my android studio path location, but for temporary fix I just rename it to gradle-2.4 and my problem solved.

Migrate project to Gradle

I've got a project that used to be in Eclipse. I've since moved it from there into Android Studio, though it's not using the Gradle build system yet.
I've setup my gradle files so that I can do gradlew build from the command-line and it will generate an APK for me.
My question now is how do I get Android studio to build using the gradle files that I've got setup instead of the using the "old" way?
For what it's worth, I'm on Windows 7.
Not sure how you are compiling the project with Android Studio without actually using Gradle because AFAIK Android Studio always uses Gradle under the hoods to build sources.
Anyway, if you have your Gradle config file ready you only have to import it to a new project in Android Studio (File > Import Project... and then select the build.gradle or settings.gradle)

Resources