Friday, 19 June 2015

Error Solving time - Android Studio - bad class file magic (cafebabe) or version (0034.0000) android studio

My friend got this error when he tried to import a project from Github, he asked me to try and see and I got the same issue as well. Finally we found that the issue was caused by the java compiler version.
Android supports 1.7 jdk version and if you are using a 1.8 version you might face this error.

This error came into picture when we tried to run the application, the normal gradle build was clean. On running the app gradle popped up with,
Local path doesn't exist 
and the cause was shown as
bad class file magic (cafebabe) or version (0034.0000) android studio

The fix:
1) Go to File > Other Settings > Default Settings > Build, Execution, Deployment > Compiler > Java Compiler, and change the Project bytecode version to 1.7

2)Go to File > Project Structure > SDK Location, here change the JDK locations path to that of a 1.7 version as below, for mac users give the jdk path till the Home folder.

Now try to build and run the project, it will be successfull. Thanks


Tuesday, 16 June 2015

Error Solving time - Android Studio - peer not authenticated

I had earlier worked on a studio project in a different machine, and after a while I thought of doing some modifications. Thankfully, I had a back up and I tried to open that project in studio in my new machine. It came up with the following error after the gradle build:

peer not authenticated

Here isthe solution, try changing the your root build.gradle's repository block as follows

repositories {
    jcenter {
        url "http://jcenter.bintray.com/"    }
}

repositories {
    maven {
        url "http://repo1.maven.org/maven2"    }
}

and rebuild your project, hopefully your error might be gone.
Happy coding :)

Tuesday, 9 June 2015

Error Solving time - Android Studio - aidl is missing

Today, my gradle came up with an error as
aidl is missing
If any of you has faced this, I would like to share as to how I solved it. There are two ways:

1) Right click on the app and select Open Module Settings and in Properties change the Build Tools Version to 22.0.1 from 23.0.0rc1. Click Ok and check, the error might be gone. But, with this method, you are not using the latest gradle version.

2) If you want to stick to using the latest gradle version (23.0.0rc1), you need to change the root gradle file's classpath as follows:
classpath 'com.android.tools.build:gradle:1.3.0-beta2'
The andriod studio latest version 1.3 preview beta version 2 is the latest that has come out and if you are going to use build toll version 23.0.0rc1 in the module file settings then you need to change accordingly in your root gradle as well.

Note: I will be posting random error fixes that I might have faced, so stay tuned.



Friday, 5 June 2015

Adding gradle dependencies when library package name is not known

Im an android developer who recently moved to Android Studio. I had this problem of finding a library dependency name that I needed to declare in the gradle. The problem started when I was trying to add the Volley library to my project, I searched all over to find the relevant package of volley which needs to be declared in the dependency set and when I tried to use the
https://android.googlesource.com/platform/frameworks/volley
The gradle build failed, and I couldnt find a proper package name. So, I thought to share with you how to add a dependency whose package name you don't know in the android studio gradle. Please follow these steps:

  1. Right click your project name (say app)
  2. Open Module Settings
  3. Select Dependencies tab
  4. Click on the + sign in the top right
  5. Choose Library Dependency
  6. In the window that opens type the library file's name(say volley) 
  7. Double click on any library file and click Ok

You will see the dependency added in your gradle and the gradle auto sync has been initiated.