Android Studio - App compiles, but won't run. See error - java

I ported my app from Eclipse to Android Studio, and now my app won't run. Just to be clear, I did not export from Eclipse. I created a new project in Android Studio, and manually cut/pasted every class in my project.
I am running Android Studio on a new Macbook Pro - Yosemite. I am having some issues running my app, even though it compiles. From what I can see, my problem might be that I am using JDK 1.8. Well, I cannot figure out how the heck to get JDK 6.
Here is the error I get when I run the project in Android Studio
Error:Execution failed for task ':app:preDexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
When I scroll up in the Gradle Event Log, I see this error:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
In addition to the app not running, Android Studio freezes a lot! Again, is this because of the version of Java I have installed?

Wait, why didn't you IMPORT the project using Android Studio? It will build the gradle files for you.
Choose New/Import Project...
Then you will see it will let you just point to the root directory of your eclipse project:

Ok, installing JDK 7 fixed the issue. So, this Macbook is brand new, running Yosemite. It didn't have a JDK installed already. When I ran Android Studio, it said no JVM found. So, I went and got the latest from Oracle. So the only JDK I had was JDK 8.
So, for whatever reason, installing JDK 7 has made it so my app will actually run... Whoo Hoo! I'm back in business.

Related

Android Studio: Application could not be installed

I've been learning android studio, today I changed just changed device for preview to Pixel did mostly layout stuff and when I run the app I get this error:
Installation did not succeed.
The application could not be installed.
List of apks:
[0] 'app\build\outputs\apk\debug\app-debug.apk'
Installation failed due to: 'closed'
I've tried to Clean Project and Build it again, I've also done Invalidate Caches. I don't know where is the problem. I also need to mention I also upgraded SDK from 14 to 16. Does that maybe cause the problem?
UPDATE
Clean Project and Build it again worked

Android Studio Gradle Sync Failed - Unsupported Java

I'm on Linux (Arch Linux) and using Android Studio 2.3.1
When creating a new empty project in Android Studio I get the error:
Gradle sync failed:
org.gradle.internal.jvm.UnsupportedJavaRuntimeException.assertUsingVersion(Ljava/lang/String;Lorg/gradle/api/JavaVersion;)V
Consult IDE log for more details (Help | Show Log)
It seems that there is something with the java version. I have openjdk-8 installed and also tried with Oracle JDK version 8 (also tried with version 7).
Things i've tried:
Using installed gradle or gradle that comes with Android Studio
Removing ~/.gradle and ~/.android.
Update:
If I enter the project directory and run gradle build i.e. using my installed gradle version it seem to build. However, being able to run gradle from Android Studio seem essential to even use Android Studio.
I upgraded to Android Studio 2.3.2 and then this particular problem was solved.
I did not use the package from AUR (Arch User Repository) when upgrading, instead I used the Android Studio "Check for updates" and upgraded that way. I don't know if that matters.
Update:
Happened again when upgrading to Android Studio 3.0.1 from AUR. Installing the official build from http://developer.android.com works though so it's some issue with the build in AUR for ArchLinux.
I had the same problem AFAIK.
Firstly I had a version previous to 3.0.1 of Android, then I downloaded the Android zip package from the official website, then installed it and kept the same old preference files (or so). Then this problem appeared. What I did is uninstalling (thus deleted the android-studio folder in terms of Ubuntu) and installing it back again and it was solved.

Android studio 2.2.2 Gradle project refresh failed

I have installed Android studio 2.2.2 in Ubuntu14.04 LTS 32 - bit machine along with OpenJDK8. And it is installed successfully.
But when i create a project or importing sample project it showing => Gradle project refresh failed.
Error:Process 'command '/home/paradigm/ANDROIDSTUDIO/android-studio/jre/bin/java'' finished with non-zero exit value 2
After updating JDK location with embedded/jvm it not changed. I did re-installed studio also. Is there any problem with Studio 2.2.2 ..?
or anything we need to set properties ..? please any one can help on this? thank you
Try to replace JRE from "/home/paradigm/ANDROIDSTUDIO/android-studio/" folder with JRE from your JDK. I had similar error with Android Device Monitor, and this, solved my problem.

Cordova Android Build Exit Code 8

I've been working on a Cordova project for iOS for the last couple of months, and now I want to move over and test the Android portion. I've tried twice of installing the Android SDK, JDK, Ant, and putting them in the Path Environment Variable but I just can't get the app to build. I tried looking around at other questions but couldn't seem to find a definitive answer.
So, when I go to build the Android platform, this is the error that I get:
BUILD FAILED
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:720: The following
error occurred while executing this line:
C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:734: Compile failed;
see the compiler error output for details.
Total time: 3 seconds
C:\Users\thomas\Desktop\batapp\BatNetting\platforms\android\cordova\node_modules\q
\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s,/c,ant/debug/-f/C:\Users\thomas\Desktop\
batapp\BatNetting\platforms\android\build.xml,-Dout.dir=ant-build,-Dgen.absoule.dir=
ant-gen
ERROR running one or more of the platforms: Error: C:\Users\thomas\Desktop\batapp\
BatNetting\platforms\android\cordova\run.bat: Command failed with exit code 8
You may not have the required environment or OS to run this project
I'm really not sure what could be causing this. Like I said, I've tried reinstalling the SDK, Java, Ant and double checked the Path. First, I tried pulling the files from a local Git server, then I removed them and copied them straight from the project I had open on the Mac VM I had been working on. I have also tried using both cordova build android and ionic build android, but both have the same result.
Any help would be greatly appreciated!
Update
I've tried creating a new app with ionic and everything in the new app works fine. I've successfully created a project, added Android as a platform, built and ran the Android project. So, it seems to be something with the app that already exists that doesn't seem to be agreeing with me.
I actually figured it out. I was just having a problem with one of my plugins. It required a java library that wasn't in my project. Once I put the library in the project, it was able to build and run fine.

First build with AndroidStudio failed

I'm new to android programming and I'd like to use Android Studio for the start. I downloaded and installed AndroidStudio 0.8.0 on my Ubuntu 14.04 machine. I also set up java properly.
When I create a new project (as told by http://developer.android.com/training/basics/firstapp/creating-project.html) it looks like it will try to build the sample files. But then I always get this error:
/home/daniel/AndroidStudioProjects/Heimweg/app/src/main/res/drawable-xhdpi/ic_launcher.png
Error:Error: Cannot run program "/home/daniel/android/android-studio/sdk/build-tools/android-4.4W/aapt": error=2, No such file or directory
Error:Execution failed for task ':app:mergeDebugResources'.
/home/daniel/AndroidStudioProjects/Heimweg/app/src/main/res/drawable-xhdpi/ic_launcher.png: Error: Cannot run program "/home/daniel/android/android-studio/sdk/build-tools/android-4.4W/aapt": error=2, No such file or directory
How can I deal with this error? When I try to run the app it says »ADB not responding. You can wait more, or kill "adb" process manually and click "Restart"«
The Android tools need 32-bit compatibility libraries installed. I had the exact same problem, and this worked for me:
sudo apt-get install libc6-i386 lib32stdc++6 \
lib32gcc1 lib32ncurses5 lib32z1
Then restart Android Studio.
It sounds like the SDK doesn't have all of the components installed!
To remedy this, in Android Studio go to Tools->Android->Android SDK Manager
I would install the Android SDK Tools, Android SDK Platform-Tools, and the Android 4.4 files (and the others as far back as you plan on developing for)
I hope this helps!
Here's some reference with pictures if you need further assistance: http://developer.android.com/tools/help/sdk-manager.html
EDIT:
I apologize! I should have read your error more carefully. It seems that android-4.4W refers to Android Wear.
Make sure when you are creating your project that you do not have Android Wear selected under the SDK selection screen (As shown below)
Alternatively you can also open up the Android SDK Manager again and install the Wear SDK.
In the SDK Manager it is under Android 4.4W (API 20), install the SDK Manager and the two System Images

Categories

Resources