I am using OkHttp 2.0.0 jar in my android application on eclipse. As OkHttp is now dependent on Okio library, I also added Okio 1.0.0 jar in my project.The project compiles fine with no compilation errors but when I run on my android device, it gives me this NoClassDefFoundError all relating to the OkHttp library classes.
I have placed all the jars in my libs folder of the project and added them to my build path and also tried checking them in the Export and Order Tab, but still it is not working.
I wanted to know since okhttp is dependent on okio, will just adding both jars would work fine or would I have to do anything different.
I have also tried the volley jar and it works all fine without any trouble.Anyone could help me out here, the problem is around for now 3 to 4 days.
Update
I also tried the android studio and added the okhttp library in the build dependency but still not working.
OkHttp v2.0 depends on Okio v1.0. You can download its jar here. This worked for me
Reference from
https://github.com/square/okhttp/issues/870
In OkHttp 2.0.0 the language level was updated to Java 7.
See Change log here https://github.com/square/okhttp/blob/master/CHANGELOG.md
In order to fix the issue you will need to update to java 7.
Also at this point you may also need change the target sdk to kitkat (API 19), and update your build tools etc in order for android to play nice with java 7
EDIT: I had the same problem when i upgraded to okHttp 2.0.0 and built with ant. Although the build seemed to succeed i got the NoClassDefFoundError. Going through my build logs I had a whole bunch of silent errors
The first came from javac
warning: com/squareup/okhttp/<classname>.class major version 51 is newer than 50, the highest major version supported by this compiler.
and the second from dex
[dx] trouble processing:
[dx] bad class file magic (cafebabe) or version (0033.0000)
[dx] ...while parsing com/squareup/okhttp/<classname>.class
[dx] ...while processing com/squareup/okhttp/<classname>.class
Go to Project/Properties/Java Build Path/Order and Export -- Make sure there's a check in front of Android Dependencies and the support library, if you use it. Mark all checkboxes and Click on Apply and clean the project.
Related
This message appears on project sync.
I've tried to clean and rebuild the project, but no success.
I'm using latest plugin version 0.12.275, "org.jetbrains.kotlin:kotlin-gradle-plugin:0.12.213" and "org.jetbrains.kotlin:kotlin-stdlib:0.12.213"
I've tried with the stable version 0.12.200 for both plugin and library, but I get the same error.
I'm using Android Studio AI-141.1972460 (canary channel).
Looks like the problem was in my *.aar lib, that was included in the project - it was compiled with an old version of Kotlin. I've upgraded the libary to the latest Kotlin version and it works now.
This issue was resolved with the updated library as mentioned by #ookami.kb
About the error message...
The "unsupported format" error comes when the ABI version number of the class files created by Kotlin does not match the expected used by the Kotlin compiler. This is no longer an issue with Kotlin 1.0 Betas since the ABI number will not change again for 1.0. But, there will be one forced recompile at 1.0 release candidate to ensure no old compiler bugs affect libraries or code and everything is rebuilt clean. Afterwards no issues such as this will exist.
Therefore if a library is not up to date with the same ABI, or hits this last "1.0 recompile" you may run into a similar error. The solution is always to find the updated library.
More about this in the Kotlin 1.0 Beta 4 announcement "What's Next" section:
After the Beta period is over, there will an RC and then 1.0.
We would really like to make sure that no code compiled with
pre-release versions of Kotlin are kept around after 1.0, so the RC
compiler will force recompilation of all the old code. We will
coordinate with library maintainers outside JetBrains to make sure
that all the widely-used libraries will be recompiled in time.
We’ll also take the opportunity to remove some legacy at this point:
remove all the deprecations that we have accumulated in the process of evolving our libraries,
remove all the deprecations from the generated code (you might not have heard of those, but they exist!),
get rid of some legacy bytecode peculiarities that were found during the beta,
move some of the stdlib code around so that the packages there have
more structure.
After that point, the only compatible changes to the
standard library are deprecations and additions (this does not include
reflection APIs). We are running an open review for the library API to
make sure we haven’t missed anything important.
This is Kotlin bug with new plugin version
Using Eclipse, is possible to generate an Android project using multidex for creating multiple
dex files? Searching over the net I found how to do that using gradle but nothing about to use that on
Eclipse without gradle
It looks like ADT's ant-tasks project is no longer maintained (it resides under 'legacy' folder).
So if you can't migrate to Gradle, you can edit the DexExecTask manually. You'll have of course to rebuild the project locally..
[Edit - 10/25/2014] maven-android-plugin does support multi-dex. However, it currently has a small issue: secondary dex files placed in wrong location. This pull request strives to fix that, so stay tuned! (Fixed in 4.0.0)
I have updated today to the latest SDKTools, r21 and the projects are no longer packed correctly.
I am using for instance ActionBarSherlock as a library project, and when I run the application I get the following error :
java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable
I have reverted back to r20 and it works again.
Did anything changed, and we should add different the library projects? I can't see something like this in the Release General Notes.
Yeh, it is ADT r21 causing it.
http://tools.android.com/download/adt-21-preview#TOC-New-in-ADT-21-Preview-5
The R classes for library projects are generated with only the IDs needed by the libraries, reducing the risk of hitting dex files limits for fields and methods.
You need to clean up the bin folder in the library project manually.
You can check the update on Tor Norbye google+ page
https://plus.google.com/116539451797396019960/posts/KVax2483Erk
Same problem but i have fixed it.
What i did:
Project / Clean / Build on all library projects
Removed the library projects and readded it on the android project
Android Tools / Fix Project Properties on the android project
Project / Clean / Build on the android project
Hope this helps and is also working for you.
I have an android 2.1 app and a separate JRE jar library with core methods of the app, compatible with other web apps. The core uses sqlite4java.
When I specify to compile the library with JRE1.6 there is no problem accessing the classes of the jar library from the app, but as the library uses sqlite4java it doesn't work because it needs to be JRE1.7 (Complains with "Couldn't load sqlite4java-android-armv6l")
When I specify to the library to compile in JRE1.7, it compiles ok, runs ok the app but when the app tries to access to any class in the library it fails with NoClassDefFoundError. During compiling I get the following error with each class of the library:
[2012-05-31 13:00:21 - AndroidApp-0.2] Dx bad class file magic (cafebabe) or version (0033.0000)
...while parsing com/androidapp/core/RES.class
...while processing com/tonads/androidapp/RES.class
I tried to put in classpath the directory where my library is but no result. Also in manifest included every .jar and .class file that the library uses.
After exhaustive googling, couldn't find any solution. Any ideas would be appreciated.
but as the library uses sqlite4java it doesn't work because it needs to be JRE1.7
First, Android does not support Java 7.
Second, since that project has an outstanding issue to confirm Java 7 compatibility, I suspect that your theory regarding Java 7 is incorrect.
Hi i'm new android. i'm working through the samples and have an error when running the HelloGridView app. Eclipse is giving the following error. Has anyone had the following error? Thanks.
[2010-12-06 14:38:16 - HelloGridView]
trouble processing "javax/net/ServerSocketFactory.class":
[2010-12-06 14:38:16 - HelloGridView]
Attempt to include a core class (java.* or javax.*) in something other
than a core library. It is likely that you have attempted to include
in an application the core library (or a part thereof) from a desktop
virtual machine. This will most assuredly not work. At a minimum, it
jeopardizes the compatibility of your app with future versions of the
platform. It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine distribution,
as opposed to compiling an application -- then use the
"--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact building an
application, then be forewarned that your application will still fail
to build or run, at some point. Please be prepared for angry customers
who find, for example, that your application ceases to function once
they upgrade their operating system. You will be to blame for this
problem.
If you are legitimately using some code that happens to be in a core
package, then the easiest safe alternative you have is to repackage
that code. That is, move the classes in question into your own package
namespace. This means that they will never be in conflict with core
system classes. If you find that you cannot do this, then that is an
indication that the path you are on will ultimately lead to pain,
suffering, grief, and lamentation.
[2010-12-06 14:38:16 - HelloGridView] 1 error; aborting
[2010-12-06 14:38:16 - HelloGridView] Conversion to Dalvik format failed with error 1
Android framework do not allow addition of JAVA core libraries in your project as external jars.
Heres how you can add libraries to your application:
Open project properties by right clicking project and selecting properties
Select JAVA build path on the left pane
Select Libraries tab from right side
Click add Library button
Select JRE system library and add required package.
I was facing the same problem, and noticed that I had added the system JRE library as one of the build path dependencies. However, the problem did not go after removing it.
I then removed the android.jar file as build path dependency, and it started working. Might be it was conflicting with an include from one of the other project dependencies, since the project was dependent on other android projects.
For people not working in english, it could also be your project name containing special characters (éàè...). I had the same problem, renamed my projects (with F2) and it worked.
I got rid of this error by checking the project dependencies and removing the Android dependencies.
In Eclipse:
Right click on the project -> properties->Java Build Path -> Libraries and there I removed the android dependencies
Check the box of System Library when you add the external jar files through Build Path--Add Libraries--User Library--User Libraries--new
I had same problem and after a couple of day of search and fight i found this thread. It does not solved my problems but helps me to find the solution.
I do this steps mentioned above:
Open project properties by right clicking project and selecting
properties.
I saw I had Android 2.1 library and Android 1.6 library.
Removed all libraries.
Changed the Android version of my project from 1.6 to 2.2.1
Clean the project
This solved my problem. The application now is working.
BTW, the application I was trying is an Android auto-answer (http://code.google.com/p/auto-answer/source/browse#svn%2Ftrunk%2Fres%2Fdrawable-hdpi)
Removing SPACES from an imported project name fixed the problem for me.