Hot questions for Using Ubuntu in android studio

Top Java Programmings / Ubuntu / android studio

Question:

I installed the java jdk1.8.0_111 and installed android studio in ubuntu 16.04 (32 bits), but when I run android studio I get the message:

Error:Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2

What should I do?


Answer:

I found the solution. I think Android Studio was using 2 java compilers, one built-in from android studio, and the other the one that I had installed in order to install Android Studio.

In Android Studio, On the menu File -> Project Structure : change the default JDK location directory to your own, in my case it was:

/usr/local/android-studio/jre

and I changed to

/usr/local/java/jdk1.8.0_111 #path_to_your_jdk

which is the version that I installed.

Question:

I am trying to get Android Studio running. I have installed jdk and jre

sudo apt-get install default-jre
sudo apt-get install default-jdk

I have set up my .bashrc and /etc/environment file to

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH

but still nothing.

$JAVA_HOME returns correct value and so do java -version and whereis javac

What am I missing?


Answer:

Following step worked for me

  1. cd to YOUR_DIR_WHERE_ANDROID_STUDIO_TILL_BIN_FOLDER
  2. then type command sh studio.sh or ./studio.sh

Question:

I am using Android Studio on Ubuntu. I started Android Studio, created a "New Project" and started it with Shift+F10. It threw the following error:

/home/laptop/AndroidStudioProjects/TestIt420/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/drawable-mdpi-v4/abc_btn_radio_to_on_mtrl_000.png
Error:Error: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/laptop/Android/Sdk/build-tools/21.1.2/aapt'' finished with non-zero exit value 127
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Information:BUILD FAILED

Also it showed me a PNG file with a circle an a transparent background with file name: abc_btn_radio_to_on_mtrl_000.png

After I just tried running the app again I now have 2 errors instead of one:

/home/laptop/AndroidStudioProjects/TestIt420/app/build/intermediates/explo     ded-aar/com.android.support/appcompat-v7/22.0.0/res/drawable-hdpi-     v4/abc_ic_ab_back_mtrl_am_alpha.png
 Error:Error: com.android.ide.common.process.ProcessException:      org.gradle.process.internal.ExecException: Process 'command      '/home/laptop/Android/Sdk/build-tools/21.1.2/aapt'' finished with non-zero      exit value 127
Error:Execution failed for task ':app:mergeDebugResources'.
>     /home/laptop/AndroidStudioProjects/TestIt420/app/build/intermediates/explo    ded-aar/com.android.support/appcompat-v7/22.0.0/res/drawable-hdpi-    v4/abc_ic_ab_back_mtrl_am_alpha.png: Error:     com.android.ide.common.process.ProcessException:     org.gradle.process.internal.ExecException: Process 'command     '/home/laptop/Android/Sdk/build-tools/21.1.2/aapt'' finished with non-zero     exit value 127
Information:BUILD FAILED

Can you maybe help me in resolving the issue?


Answer:

You have to install These Packages to Solve this Error Because Android SDK Still not working on UBUNTU 64 Bit.

sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

Question:

I have an issue with Android Studio on Ubuntu. Until now, I used to run Android Studio in console mode by going to the android-studio/bin folder and running studio.sh. It works well, but it's boring for me type the commands each time I want to run it, I'd prefer to open it simply clicking on a shortcut. So, I tried to create a shortcut in my task bar.

In /usr/share/applications, I created a file named "android-studio.desktop". Here is the content of the file :

[Desktop Entry]
Type=Application
Terminal=false
Name=Android Studio
Icon=/home/chugrothas/android-studio/bin/androidstudio.svg
Exec=/home/chugrothas/android-studio/bin/studio.sh

Then I dragged the desktop file onto the task bar. When I try to open Android Studio using my new shortcut, I get :

No JDK found. Please validate either STUDIO_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.

However, when I run the command echo $JAVA_HOME, I get the following path :

/home/chugrothas/jdk1.7.0_71

And in my PATH variable (just copying the end of the PATH content) :

:/home/chugrothas/jdk1.7.0_71/bin

Because Android Studio works when I run it using command lines & because JAVA_HOME is correctly set, I don't understand why my shortcut does not work...

I searched on the internet and didn't find anybody in the same situation. It's not a big problem because I can still run AS, but I'd really like to understand why the shortcut does not work.

Thank you for your help !


Answer:

Probably your JAVA_HOME is not found here.

You can define it as a system-wide environment variable in /etc/environment eg. like this:

sudo nano /etc/environment

and add the following line to the end:

JAVA_HOME="/home/chugrothas/jdk1.7.0_71"

Save and reboot your box.

Note: you can let Android Studio create the desktop entry on the Dash for you, eg. from the welcome window (Configure / Create Desktop Entry) or Tools / Create Desktop Entry... It will create the file jetbrains-android-studio.desktop in ~/.local/share/applications.

Question:

I use Android Studio 3.1.4 on Ubuntu 18.04.1. I wanted to quickly create the UI of the main (default) activity so I opened the Layout Editor. Some errors have occurred. Then I tried to add a button: it doesn't seem to be displayed in the Blueprint (and the ConstraintLayout is weirdly displayed too).

Similar StackOverflow questions - Android support library

Similar questions have been asked in StackOverflow. The answers were to use a different version of the Android support library. Currently, I'm using this version:

implementation 'com.android.support:appcompat-v7:28.0.0-rc01' (file: build.gradle(Module: app)).

Indeed, even if Android Studio recommended me to use 28.0.0-rc02, I don't see it in this list: https://mvnrepository.com/artifact/com.android.support/design?repo=google .

By the way, I encountered all of the mentionned bugs with 28.0.0-rc02 too. In résumé, I encounter all of these bugs with 28.0.0-rc01 (currently used) and 28.0.0-rc02. I didn't try other versions for the moment.

Using implementation 'com.android.support:appcompat-v7:27.1.1

With implementation 'com.android.support:appcompat-v7:27.1.1', all the problems are solved. However:

  1. It's not the last version (https://mvnrepository.com/artifact/com.android.support/design?repo=google indicates the last version is: 28.0.0-rc01, Android Studio indicates it's 28.0.0-rc02 - both bug)

  2. Android studio underlines in red my implementation instruction as follows:

Errors opening the Layout Editor
  1. Render problem

Failed to load AppCompat ActionBar with unknown error.

  1. The following classes could not be instantiated

- android.support.v7.widget.ActionBarContainer (Open Class, Show Exception, Clear Cache) - android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache) - android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)

Exception Details:

java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:180) at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:61) at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:118) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.jetbrains.android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.java:213) at android.support.v7.widget.ActionBarContainer.(ActionBarContainer.java:62) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:481) at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:264) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:222) at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:209) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.android.layoutlib.bridge.bars.BridgeActionBar.(BridgeActionBar.java:89) at com.android.layoutlib.bridge.bars.AppCompatActionBar.(AppCompatActionBar.java:68) at com.android.layoutlib.bridge.impl.Layout.createActionBar(Layout.java:277) at com.android.layoutlib.bridge.impl.Layout.(Layout.java:161) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:288) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

Blueprint problems - What is in my UI?

For the moment, nothing apart the root component (a ConstraintLayout instance), as you can see (note that the ConstraintLayout seems to be represented as a very little square in the Blueprint - that's a Blueprint problem, no?):

If I drag'n drop a button with the text "TEST TEST TEST" in the Blueprint, I get this (note that the button... doesn't really appear, only a weird thing is displayed inside the square):

I clicked several time on this square with a weird thing inside. I got this new exception:

Missing Constraints in ConstraintLayout

This view is not constrained vertically: at runtime it will jump to the top unless you add a vertical constraint The layout editor allows you to place widgets anywhere on the canvas, and it records the current position with designtime attributes (such as layout_editor_absoluteX). These attributes are not applied at runtime, so if you push your layout on a device, the widgets may appear in a different location than shown in the editor. To fix this, make sure a widget has both horizontal and vertical constraints by dragging from the edge connections.

My question

I'm a little lost in the middle of all these mistakes and exceptions. What am I supposed to do? I'm reading again the documentation ( https://developer.android.com/training/basics/firstapp/building-ui) but they don't seem to have this weird behavior (I'm talking about problems displaying my button in the Blueprint and the exceptions I copied/pasted in this question).

Important edit

Which version of Android Support Library should I use? In particular: what should I do to use the latest version? (either rc-1, or rc-2 - Android Studio recommends the rc-2 but this one doesn't appear in https://mvnrepository.com/artifact/com.android.support/design?repo=google )


Answer:

Latest Versions of Support libraries is still under development and may contain bugs

Until it ends you can downgrade version to 28.0.0-alpha1

implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'

Question:

I have followed the instructions on the official site.

But I am unable to install Android Studio. I'm getting error message "An error occurred while trying to compute required packages" as shown in the attached image.

Few months back when I tried to install Android Studio there are instruction in Android Studio official webpage to install Java JDK. Today I don't find any traces about it. Do I need to install any Java related file to fix the error?


Answer:

Of course you need to install the Java Development Kit.

sudo apt-get install openjdk-8-jdk

... e.g. in the terminal should do the trick.

EDIT:

There's a manual workaround!

As per post https://stackoverflow.com/a/42733510/7694425 :

  1. Download the command line tools, place them in the SDK folder (e.g., on mac: /Users/user/Library/Android/sdk), and then add the bin folder to the PATH.
  2. Install the latest platform: in a terminal, execute sdkmanager "platforms;android-25"
  3. Open Android Studio, and go to the SDK Manager (Appearance and Behavior > System Settings > Android SDK)
  4. Click on "Edit", and then select the sdk folder. Then "Next" > "Next" > "Finish".

Still, it doesn't resolve the missing emulator package therefore the Android SDK tools can't be updated since it's a dependency. But Android studio works and you can download other packages.

Looking forward to a better solution.

Update 2:

Solution to emulator package issue!

After digging in the repo's XML for a while I've spotted the issue.

It turns out that the "emulator" package is only in channel 3 (canary) while the "tools" package is in channel 0 (stable) but depends on "emulator". The solution is to force the manager to download the "emulator" package from channel 3:

./sdkmanager --channel=3 emulator

Problem solved!

Question:

I have installed android studio in Ubuntu 16.04. If I start a project then run button is automatically disabled.I have installed all the packages in SDK. The error shows as below.

And the log message shows as below.

    WARN - nal.AbstractExternalSystemTask - Cause: error=13, Permission denied 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cause: error=13, Permission denied
    at 

    org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
        at 

org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
    at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:579)
    at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:158)
    at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:405)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:772)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:752)
    at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:238)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:112)
    at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:73)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
    at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
    at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
    at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
    at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
    at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:369)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

[ 196770]   WARN - radle.project.ProjectSetUpTask -  
[ 197344]   WARN - roid.tools.ndk.GradleWorkspace - NDK support for project 'ActionBarCompat-ShareActionProvider' is disabled because the project doesn't contain any valid native configurations.

Please help me to resolve this error.


Answer:

I reinstalled android studio by standard installation. Installed all the SDK components at the time of installation. Now the issue was solved.

Question:

i just installed Xubuntu x32 bit. Then i installed android studio and java sdk. But when i open android studio project it shows me:

"Error:Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2"

This is the terminal output:

nal.AbstractExternalSystemTask - Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2

This is JAVA_HOME path:

export JAVA_HOME="/usr/lib/jvm/jdk1.8.0_101" 
export PATH="$PATH:$JAVA_HOME/bin"

Answer:

Choose File->Project Structure Write your /usr/lib/jvm/jdk1.8.0_101 to "JDK location". It`s help to me with the same problem. But you must have write permissions to /usr/local/android-studio.

I have installed studio in my home folder.