Import a Gradle project into Android project - android

I'm working on an android Project which i'd like to import another existing project developed with gradle. So, i've got successfully integrated that gradle project inside Eclipse. I've imported the gradle project and i can see and instantiate the classes from the gradle project, but when i launch the android project it throws the next log by the console:
[2014-10-06 09:10:42 - Pdf2jpg-V3] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:883)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...while parsing simple/escp/Template.class
[2014-10-06 09:10:43 - Pdf2jpg-V3] Dx 1 error; aborting
[2014-10-06 09:10:43 - Pdf2jpg-V3] Conversion to Dalvik format failed with error 1
To import the gradle project to my android project i tried in two ways:
1- Exporting a JAR from the gradle project and importing as external jar and checking it with the build path
2- adding the whole gradle project to the build path from the android project.
Both throws the same exception.

Finally the problem was the compliance level in the Gradle proeject (1.8), so, i updated the project to 1.6 (like my android project) and also updated the instances that were working only in 1.8 to be now working in 1.6.
My problem now is that it seems that the jar references included in the gradle project are not working, but in fact theay are included are gradle references as below:
So, the execution throws class not found exception:
java.lang.NoClassDefFoundError: javax.json.JsonObject
...Though javax.json is included, any idea??

Related

How to level Maven dependencies in Android Studio

I have tried to add a library (odata4j) in Android Studio 1.1.0.
I used the Project Structure:
When Gradle started to sync, it gave me this error:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find org.eclipse.persistence:eclipselink:2.1.2.
Searched in the following locations:
https://jcenter.bintray.com/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
https://jcenter.bintray.com/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/android/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/android/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/google/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.pom
file:/C:/Users/Nestor/AppData/Local/Android/sdk/extras/google/m2repository/org/eclipse/persistence/eclipselink/2.1.2/eclipselink-2.1.2.jar
Required by:
MyApp:app:unspecified > org.odata4j:odata4j-dist:0.7.0 > org.odata4j:odata4j-core:0.7.0
So, to take care of it, I searched for eclipselink in the library dependency selector:
After I added it, Gradle could sync but on compile, I get another error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing org/eclipse/persistence/internal/indirection/jdk8/IndirectCollectionsProvider.class
1 error; aborting
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0\bin\java.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
It seems, eclipselink uses Java 8 so it can't work together with my Java 7 Android application.
What should I do to make this work?

Error building Player: CommandInvokationFailure: Unable to convert classes into dex format

Please help me to solve this problem. This is what i got in the console:
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0_25\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/Android SDK/sdk\tools" -Dfile.encoding=UTF8 -jar "D:/Unity3D/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/qn;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:732)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:130)
1 error; aborting
]
stdout[
processing archive bin\classes.jar...
processing com/unity3d/player/a$1.class...
processing
and a million of procesing somethings ... it took 320k line so i wasnt able to paste it here.
This usually happens for the plugins. Search for any duplicate jar in the explorer of your project. Delete any duplicates. If it doesn't solve your problem, try deleting your "Plugins" folder of your project and then re-import all your plugins. Hope it will be solved.
I solved this problem by simply changing the java path from Open Unity go to Edit --> Preferences --> External Tools in JDK . (this jdk folder was actually running on system).

Android: UNEXPECTED TOP-LEVEL EXCEPTION

I got an error while compiling my libgdx project with gradle.
Execution failed for task ':android:preDexAmazonDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/SDK-PATH/Android/build-tools/21.0.1/dx --dex --output /PATH/android/build/intermediates/pre-dexed/Amazon/debug/core-1.0-47e2423a0159bad5774996683a8ab834009ab7ed.jar /PATH/core/build/libs/core-1.0.jar
Error Code:
1
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:82)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing org/mars3142/OwnClass.class
1 error; aborting
I didn't include core twice into my Android project. I double checked, if I include some external libs, but it seems, that my own project is the failure, which I can't understand, because I never changed something. I only added an android-wear project into my project. And if I go back into time (with git), it also is not compileable.
EDIT: If I hit run in IntelliJ for the same build variant (AmazonDebug) it works like expected. That's really strange.

Getting Error with crouton in Eclipse

currently I´m getting a "Conversion to Dalvik format failed with error 1". I already searched the web after solutions but did not find something that works for me. It seems to have something to do with the crouton library, that I´ve added in the past. I currently do not have installed the library. How can I fix / remove the Library?
Here is the error I get from the console:
*
[2014-03-19 19:40:53 - UltimateCookbook] Conversion to Dalvik format
failed with error 1 [2014-03-19 19:41:45 - UltimateCookbook] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name
(de/keyboardsurfer/android/widget/crouton/Configuration$1) does not
match path
(release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class)
at
com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
at
com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at
com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at
com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.processClass(Main.java:665) at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:634) at
com.android.dx.command.dexer.Main.access$600(Main.java:78) at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596) at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:498) at
com.android.dx.command.dexer.Main.runMonoDex(Main.java:264) at
com.android.dx.command.dexer.Main.run(Main.java:230) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
java.lang.reflect.Method.invoke(Unknown Source) at
com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:187)
at
com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
at
com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
at
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328)
at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403)
at
org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at
org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
at
org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at
org.eclipse.core.internal.resources.Project.build(Project.java:124)
at
com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
at
com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1018)
at
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1222)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) ...while
parsing
release/de/keyboardsurfer/android/widget/crouton/Configuration$1.class
*
When I am deleting the library in Windows myself, I only get more errors even if it is not used anymore (I think).

Error when building with Android Annotations

I'm using the guide here to integrate Android Annotations in my Eclipse project (no Maven). I've got the latest ADT running, and tried cleaning my project, double checking build paths and order/export, and turning annotations on and off, but whenever I add the Android Annotations jar to the entries under Java Compiler > Annotation Processing > Factory Path in Eclipse, I get this error:
Error
Mon Jul 15 18:01:05 PDT 2013
Errors running builder 'Java Builder' on project 'Shopping'.
java.lang.NoClassDefFoundError: org/androidannotations/annotations/EActivity
at org.androidannotations.AndroidAnnotationProcessor.getSupportedAnnotationTypes(AndroidAnnotationProcessor.java:601)
at org.eclipse.jdt.internal.compiler.apt.dispatch.ProcessorInfo.<init>(ProcessorInfo.java:58)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.discoverNextProcessor(IdeAnnotationProcessorManager.java:94)
at org.eclipse.jdt.internal.compiler.apt.dispatch.RoundDispatcher.round(RoundDispatcher.java:116)
at org.eclipse.jdt.internal.compiler.apt.dispatch.BaseAnnotationProcessorManager.processAnnotations(BaseAnnotationProcessorManager.java:159)
at org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager.processAnnotations(IdeAnnotationProcessorManager.java:134)
at org.eclipse.jdt.internal.compiler.Compiler.processAnnotations(Compiler.java:820)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:434)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:365)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.compile(BatchImageBuilder.java:178)
at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:302)
at org.eclipse.jdt.internal.core.builder.BatchImageBuilder.build(BatchImageBuilder.java:60)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildAll(JavaBuilder.java:254)
at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:173)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:394)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:114)
at org.eclipse.jdt.internal.ui.util.CoreUtility$BuildJob.run(CoreUtility.java:161)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassNotFoundException: org.androidannotations.annotations.EActivity
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 29 more
Anyone have a fix?
You might have copied the wrong of the 2 jars. Please check carefully, where you place the one with and without "api" in the name (as given on the configuration page).
Besides that I guess you have checked all steps from the trouble shooting section.
It turned out to be a bug with my snapshot of Android Annotations. Reverting to the stable 2.7.1 works!

Categories

Resources