UcasRichard / snakeyaml

Automatically exported from code.google.com/p/snakeyaml
Apache License 2.0
0 stars 0 forks source link

add android support. #92

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
what ever it means...
see http://stackoverflow.com/questions/4054083/ as a start point.

Original issue reported on code.google.com by alexande...@gmail.com on 3 Nov 2010 at 12:43

GoogleCodeExporter commented 9 years ago
see the following blog to make your own Android version based on the current 
code base
http://aleksmaus.blogspot.com/2012/01/yaml-parser-for-android.html

Original comment by Alain.Fa...@gmail.com on 17 Feb 2012 at 2:38

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 86cd9dc4776e.

now you can build android version of snakeyaml by activating android profile: 
-Pandroid

Original comment by alexande...@gmail.com on 22 Feb 2012 at 12:17

GoogleCodeExporter commented 9 years ago
few word about last comment

android profile takes current sources (excluding some - MethodProperty at the 
moment) and applies patches from `src/main/patches/android` to remove some 
`java.beans.InrospectXXX` dependencies.

During android build test failures are ignored, but not test errors.
Most (if not all) failures come from the assumption that `BeanAccess.DEFAULT` 
is used (getter/setters + public fields). But in android version, *fields are 
ALWAYS used* (`BeanAccess.FIELD`).

Maybe in the future we redesign tests to be grouped by BeanAccess... + run 
tests under android environments.

Original comment by alexande...@gmail.com on 22 Feb 2012 at 1:04

GoogleCodeExporter commented 9 years ago
Will an Android version like shown on the download page, ever make it to maven?

Original comment by connor.tumbleson on 19 Mar 2014 at 9:56

GoogleCodeExporter commented 9 years ago
Most probably it will, but can't say when.

BTW, android version on the download page is outdated.

At the moment you can get android version into your local repository from the 
sources:

mvn -Pandroid clean install

and then reference it as dependency in your pom.xml with 
<classifier>android</classifier>

Not the best way, but at the moment it is THE way :)

Original comment by alexande...@gmail.com on 20 Mar 2014 at 8:46

GoogleCodeExporter commented 9 years ago
I've built an Android version of snakeyaml, but I'm getting an error when 
running:

Thread [<1> main] (Suspended (exception VerifyError))   
    <VM does not provide monitor information>
    Representer.<init>() line: 43
    Yaml.<init>() line: 63

Also, I get test failures when building and have to use -DskipTests for it to 
work.

Results :

Failed tests: 
  testGenericBean(org.yaml.snakeyaml.issues.issue61.GenericMapBeanTest)
  testGenericMap(org.yaml.snakeyaml.issues.issue61.GenericMapBeanTest)
  testRootMap(org.yaml.snakeyaml.constructor.ImplicitTagsTest)

Tests run: 829, Failures: 3, Errors: 0, Skipped: 0

I cloned with repo with hg.

Original comment by mohdakra...@gmail.com on 21 May 2014 at 8:30

GoogleCodeExporter commented 9 years ago
any more info like exact commands you are using, java version, OS ?

Original comment by alexande...@gmail.com on 21 May 2014 at 8:38

GoogleCodeExporter commented 9 years ago
I tried both:

mvn -DskipTests -Pandroid clean install

and

mvn -DskipTests -Pandroid clean package

Using ADT on Windows 7 32-bit.
Compiler compliance level: 1.7

More info from logcat:

05-15 00:58:28.451: W/dalvikvm(9588): VFY: unable to resolve exception class 
1030 (Ljava/beans/IntrospectionException;)
05-15 00:58:28.451: W/dalvikvm(9588): VFY: unable to find exception handler at 
addr 0x11
05-15 00:58:28.451: W/dalvikvm(9588): VFY:  rejected 
Lorg/yaml/snakeyaml/representer/Representer$RepresentJavaBean;.representData 
(Ljava/lang/Object;)Lorg/yaml/snakeyaml/nodes/Node;
05-15 00:58:28.451: W/dalvikvm(9588): VFY:  rejecting opcode 0x0d at 0x0011
05-15 00:58:28.461: W/dalvikvm(9588): VFY:  rejected 
Lorg/yaml/snakeyaml/representer/Representer$RepresentJavaBean;.representData 
(Ljava/lang/Object;)Lorg/yaml/snakeyaml/nodes/Node;
05-15 00:58:28.461: W/dalvikvm(9588): Verifier rejected class 
Lorg/yaml/snakeyaml/representer/Representer$RepresentJavaBean;

I checked the target/android/src folder and the patch was indeed applied on 
Representer.

Original comment by mohdakra...@gmail.com on 21 May 2014 at 9:03

GoogleCodeExporter commented 9 years ago
I'm running Android 4.4.2 in a VM.

Original comment by mohdakra...@gmail.com on 21 May 2014 at 9:08

GoogleCodeExporter commented 9 years ago
Ok. First of all you shouldn't be using -DskipTests (see comment #3).

But that's does not seem to be the reason. I have tried couple of things and 
seems like you are using wrong file in your project.

After maven -Pandroin clean install you will have few jars in target/ folder.
You need the one which ends with -android.jar

Put it into lids/ folder of your android project and VerifyError should 
disappear.

Original comment by alexande...@gmail.com on 21 May 2014 at 10:23

GoogleCodeExporter commented 9 years ago
No jar files are generated. I've attached the output of:

mvn -Pandroid clean install > log.txt

Original comment by mohdakra...@gmail.com on 21 May 2014 at 10:36

Attachments:

GoogleCodeExporter commented 9 years ago
could you also paste here mvn -version output ?

Original comment by alexande...@gmail.com on 21 May 2014 at 10:48

GoogleCodeExporter commented 9 years ago
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 
2014-02-14T21:37:52+04:00)
Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.2.1
Java version: 1.8.0_05, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_05\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"

Original comment by mohdakra...@gmail.com on 21 May 2014 at 10:50

GoogleCodeExporter commented 9 years ago
Ok. thx

This is actually not android related issue, because mvn clean install fails 
also 
A have created issue191 about java 8 build failure.

At the moment I see the only way to build snakeyaml from sources - use java 7.

Original comment by alexande...@gmail.com on 21 May 2014 at 11:00

GoogleCodeExporter commented 9 years ago
Actually you can try -DskipTests with latest sources (first: hg pull -u) under 
java 8.

Those Failures in tests are connected to properties order in generated yaml 
(I'd say those tests need to be "re-evaluated").

If you will not end up with something like this
***********************
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-antrun-plugin:1.7:run (build-for-android) on 
project snakeyaml: An Ant BuildException has occured: Unable to find a javac 
compiler;
[ERROR] com.sun.tools.javac.Main is not on the classpath.
[ERROR] Perhaps JAVA_HOME does not point to the JDK.
[ERROR] It is currently set to 
"/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/jre"
[ERROR] around Ant part ...<javac includeantruntime="false" debug="true" 
classpath
************

You will get needed jars in target folder.

Original comment by alexande...@gmail.com on 21 May 2014 at 11:30

GoogleCodeExporter commented 9 years ago
I compiled now with Java 8 and it worked, thanks!

I previously got this error and had to add fork="true" in the javac entries of 
pom.xml.

Original comment by mohdakra...@gmail.com on 21 May 2014 at 12:31

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 1413062d7874.

added fork="true" to <javac> ant-task to prevent maven-antrun-plugin crash (thx 
to @mohdakram12)

Original comment by alexande...@gmail.com on 21 May 2014 at 1:07