2

I will really appreciate any help or insight here.

I need to config Android Studio (2.2.1 latest) but it is being a pain! Just after to be installed, I use the wizard (new project) to create a totally blank "app" only using defaults.

Just after the app to be created, AS2 give me this: Gradle 'MyApplication' project refresh failed like in the following image:

error

It is VERY frustrating when you install a program, use all defaults to make something, and it gives an error just on open!

I tried to reinstall everything, even cleaning .java, .gradle, .androidXXX, tryed so many solutions here in the SoF, and still nothing. Same error since yesterday!

My specs:

  • Java 1.8 Oracle (with JDK, everything working in other programs)
  • Linux Mint 18
  • Android Studio 2.2.1
  • Gradle 2.14.1 (as i can see in android-studio/gradle/ folder)

Please, any help, idea, guessing or any else for this? Thanks in advance!

--edit--
Some logs that could be relevant:

2016-10-17 01:01:50,059 [  67026]   INFO - radle.project.ProjectSetUpTask - Process 'command '/home/sidney/bin/android-studio/jre/bin/java'' finished with non-zero exit value 2

Consult IDE log for more details (Help | Show Log) 
2016-10-17 01:01:50,059 [  67026]   INFO - ls.idea.gradle.GradleSyncState - Sync with Gradle for project 'My Application' failed: Process 'command '/home/sidney/bin/android-studio/jre/bin/java'' finished with non-zero exit value 2

Consult IDE log for more details (Help | Show Log) 
2016-10-17 01:01:50,176 [  67143]   WARN - roid.tools.ndk.GradleWorkspace - NDK support for project 'My Application' is disabled because the project doesn't contain any valid native configurations. 
2016-10-17 01:01:50,444 [  67411]   INFO -       #com.jetbrains.cidr.lang - Clearing symbols finished in 0 s. 
2016-10-17 01:01:50,448 [  67415]   INFO -       #com.jetbrains.cidr.lang - Loading symbols finished in 0 s. 
2016-10-17 01:01:50,453 [  67420]   INFO -       #com.jetbrains.cidr.lang - Building symbols finished in 0 s. 
2016-10-17 01:01:50,454 [  67421]   INFO -       #com.jetbrains.cidr.lang - Saving symbols finished in 0 s. 
2016-10-17 01:02:59,434 [ 136401]   WARN - ConfigurableExtensionPointUtil - ignore deprecated groupId: editor for id: editor.preferences.import 
2016-10-17 01:03:25,793 [ 162760]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /home/sidney/bin/android-studio/jre 
2016-10-17 01:03:25,794 [ 162761]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from /home/sidney/bin/android-studio/jre 

--edit--
Since AS Gradle Console won't let me type, I've installed gradle system-wide via apt-get and run gradle --debug on MyApplication root. The output can be seen here (too long to post here)

sdlins
  • 2,195
  • 1
  • 23
  • 31
  • What gradle version are you using? – Mohit Sharma Oct 17 '16 at 01:37
  • @MohitSharma I have updated the specs. Thnx – sdlins Oct 17 '16 at 02:28
  • please try this: type gradlew --debug in the terminal of android studio. it will show why the problem happen – Omid Heshmatinia Oct 17 '16 at 03:09
  • @Smartiz I dont know why, but my Gradle Console won`t let me type! :-/ Sorry, I am just trying to make that (stupid?) AS to work so that I can study android development so that I am not experienced with android[-studio]. Am I doing something wrong or should that console be working 'out-of-the-box'? (Thank u so much, anyway) – sdlins Oct 17 '16 at 03:18
  • 1
    @Smartiz I installed grade in system-wide mode via apt-get so I executed `gradle --debug` in `MyApplication` root. It took about 2 minutes but finished with **no error**. I am updating the question with those logs too. Thanks. – sdlins Oct 17 '16 at 03:35
  • You have Oracle JDK installed, but that error message is not using the JDK. It is using the default JRE that is bundled in Android Studio. You should try to update the SDK settings – OneCricketeer Oct 17 '16 at 03:54
  • @cricket_007 Could you please post it like an answer? I think your answer FINALLY has fixed my problem. I found how to change JDK in Android and after do that my Graple Build is **running** right now! I can see some other errors but it seems to be other problems. I will wait it finish to make the correct assumption. Guy, thank you SO much!!! – sdlins Oct 17 '16 at 04:10
  • I'll wait and see if your build finishes before posting an answer – OneCricketeer Oct 17 '16 at 04:18
  • Ok. I see this: `2:01:54 AM Gradle sync started 2:02:53 AM Gradle sync completed 2:02:53 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]` and Gradle Build task is *still* running! – sdlins Oct 17 '16 at 04:26
  • Ok! I changed gradle configs to use 'offline' (learned here in SoF) and then I `xkilled` it since it was taking too much time. After restart, *everything* works like a charm! Thank you SO MUCH! – sdlins Oct 17 '16 at 04:33

1 Answers1

1

In the debug output, you can see

Instructing gradle to use java from /home/sidney/bin/android-studio/jre

Now, if you notice that path, that's the JRE, not the Oracle JDK. I'm honestly not sure why Android Studio ships with a buggy Java JRE, what version it is, why it's the default, or even recommended, but find the IDE settings for setting up the correct JDK.

Hopefully it'll run successfully after that.

It might take a while to build and download some dependencies the first time, but should be faster after that. If you don't plan on downloading many libraries to start out, you can enable Offline Mode to have it be quicker

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Ok. Thank you for help me about this. I fixed this problem and now I have another (emulator related)... Android Studio **really sucks**! I am just persisting because Udacity uses this IDE, so I have no choice in this case. Thanks. – sdlins Oct 17 '16 at 15:31
  • I use Intellij IDEA, not Android Studio. A lot of people like it more than Eclipse. You just need a computer with decent hardware to use it – OneCricketeer Oct 17 '16 at 16:05
  • I never used Idea (not mainly a java programmer), but other two (three including AS2) JetBrains IDEs. But, about Idea I found that in their site: "IntelliJ IDEA provides the *same* coding assistance and integrated toolset for developing Android applications *as Android Studio*, the official IDE for Android application development from Google." So, I am not so confident for now :) – sdlins Oct 18 '16 at 00:30
  • The Android plugin provides the same tools, but Android Studio includes additional quickstarts and wizards specifically for Android development – OneCricketeer Oct 18 '16 at 01:21