jcabi-github icon indicating copy to clipboard operation
jcabi-github copied to clipboard

Does jcabi-github support Android?

Open letroll opened this issue 10 years ago • 48 comments

Hello did you know if jcabi-github work on Android?

letroll avatar Nov 28 '14 08:11 letroll

@letroll I haven't tried, but I don't see any reasons why it wouldn't.. please, try and let us know if something doesn't work, we'll try to fix

yegor256 avatar Nov 28 '14 11:11 yegor256

Hi guys, it seems that importing javax.xml.bind.DatatypeConverter won't make it work on Android...

Was currently debugging some bug on Android Device, and I found this similar problem : https://github.com/fernandezpablo85/scribe-java/issues/359

Checked out the constructor in RtGitHub.java, at line 117 :

public RtGithub(
        @NotNull(message = "user name can't be NULL") final String user,
        @NotNull(message = "password can't be NULL") final String pwd) {
        this(
            RtGithub.REQUEST.header(
                HttpHeaders.AUTHORIZATION,
                String.format(
                    "Basic %s",
                    DatatypeConverter.printBase64Binary(
                        String.format("%s:%s", user, pwd)
                            .getBytes(Charsets.UTF_8)
                    )
                )
            )
        );
    }

and in line 43:

import javax.xml.bind.DatatypeConverter;

According to my Logcat, the program is throwing exception once the constructor is called.

ray1007 avatar Dec 10 '14 02:12 ray1007

With my logcat !

12-10 10:26:32.430  29155-29543/ray.nm_final_test2 I/dalvikvm﹕ Could not find method javax.xml.bind.DatatypeConverter.printBase64Binary, referenced from method com.jcabi.github.RtGithub.<init>
12-10 10:26:32.435  29155-29543/ray.nm_final_test2 W/dalvikvm﹕ VFY: unable to resolve static method 18449: Ljavax/xml/bind/DatatypeConverter;.printBase64Binary ([B)Ljava/lang/String;

besides I'm including jcabi-github-0.18-jar-with-dependencies.jar

ray1007 avatar Dec 10 '14 02:12 ray1007

sounds like a bug on our side. let us try to fix it.

yegor256 avatar Dec 10 '14 07:12 yegor256

@lthuangiang the task is yours, the budget is 30 mins, please go ahead

dmarkov avatar Dec 10 '14 10:12 dmarkov

@lthuangiang the task is overdue, and I have to re-assign it to someone else. Please, stop working with it immediately. In general, we're against overdue tasks, check this page

dmarkov avatar Dec 30 '14 10:12 dmarkov

@nathansgreen the task is yours

dmarkov avatar Dec 31 '14 07:12 dmarkov

@dmarkov please assign to someone else.

nathansgreen avatar Jan 12 '15 02:01 nathansgreen

@dmarkov please assign to someone else.

@nathansgreen right, I will find someone else, no problem

dmarkov avatar Jan 12 '15 11:01 dmarkov

@pinaf please go ahead, it's your task now, keep this in mind, and don't hesitate to ask any technical questions you may have

30 mins is the budget of the task. This is exactly how much will be paid when the problem is solved (no matter how much time you will actually spend). See this for more information

dmarkov avatar Jan 14 '15 12:01 dmarkov

@dmarkov please assign to someone else - no experience with android dev and no phone to test.

pinaf avatar Jan 14 '15 14:01 pinaf

@dmarkov please assign to someone else - no experience with android dev and no phone to test.

@pinaf got it, someone else will be assigned soon

dmarkov avatar Jan 15 '15 14:01 dmarkov

@oruam85 the task is yours

dmarkov avatar Jan 20 '15 11:01 dmarkov

@dmarkov please assign to someone else

oruam85 avatar Jan 22 '15 01:01 oruam85

@dmarkov please assign to someone else

@oruam85 got it, someone else will be assigned soon

dmarkov avatar Jan 22 '15 07:01 dmarkov

@adko-pl the task is yours

dmarkov avatar Feb 23 '15 08:02 dmarkov

@dmarkov please assign to someone else

adamsiemion avatar Feb 25 '15 11:02 adamsiemion

@dmarkov please assign to someone else

@adko-pl I will assign somebody else to this issue

dmarkov avatar Feb 26 '15 07:02 dmarkov

There are two issues here.

  1. The RtGithub class creates the USER_AGENT constant using the manifest file. Android repacks all libraries and the 'JCabi-Version' property and other similar properties doesn't exist in apk. All RtGithub constructors don't work. They throw:
java.lang.IllegalArgumentException: Attribute 'JCabi-Version' not found in MANIFEST.MF file(s) among 2 other attribute(s): ["Created-By", "Manifest-Version"]

Solutions: 1.1) build simple constant (my PR do that :( )

or

1.2) create a resource properties file that will contain this property. It can be created during maven build (better solution)

  1. The second problem is described above. It happens when first issue is solved and only for "new RtGithub(user,pwd)" constructor.

The Dalvik can't find javax.xml.bind.DatatypeConverter

Solutions:

2.1) bypass somehow Android restriction (repack jar or similar...). I haven't managed to solve the problem this way, although there are different recommendations.

or

2.2) I have created the RtDatatypeConverter class based on DatatypeConverterImpl from OpenJDK. The class will use standard DatatypeConverter if exists or the method(s) copied from DatatypeConverterImpl.

I have tested the following code:

RtGithub github = new RtGithub("pecko", "MYPWD");
Repo repo = github.repos().get(new Coordinates.Simple("jcabi/jcabi-github"));
Issues issues = repo.issues();

within a Android activity.

Notice: The PR probably requires some improvement, but, for now, I have analyzed the issue and made simple PR. Please advice.

There are also some comment in the code.

pecko avatar Sep 22 '15 03:09 pecko

I have also fixed checkstyle errors in RtGithub, but I have just excluded that from RtDatatypeConverter because it is mostly copied. PMD errors are fixed.

pecko avatar Sep 22 '15 04:09 pecko

@darkled I will solve all issues you described in the PR, but firstly want to that we agree about solutions. I have described two issues and offer two solutions. You want to say that my solution are fine beside soving your comment. Right?

pecko avatar Sep 22 '15 12:09 pecko

@darkled @dmarkov

I have committed final solution (I hope). It builds on my local machine. I have also updated the PR description. See https://github.com/jcabi/jcabi-github/pull/1162/

pecko avatar Sep 22 '15 20:09 pecko

AppVeyor and Travis have passed. All seems good.

pecko avatar Sep 22 '15 20:09 pecko

@pecko This task is yours, please go ahead keeping in mind this. If any questions, don't hesitate to ask right here. This task's budget is 30 mins. This is exactly how much will be paid when the problem explained above is solved. See this for more information

dmarkov avatar Sep 28 '15 07:09 dmarkov

@dmarkov

I have solved what I can. Please look at https://github.com/jcabi/jcabi-github/pull/1162. Travis, AppVeyor passed with no issues, but rultor fails. I have open the issue against rultor https://github.com/yegor256/rultor/issues/940

pecko avatar Sep 28 '15 09:09 pecko

@darkled @dmarkov

I have updated the PR based on comment at https://github.com/yegor256/rultor/issues/940#issuecomment-143786271

pecko avatar Sep 28 '15 16:09 pecko

@darkled @dmarkov

I have changed commit/ It just fixes puzzle instead of remove it. I'm not sure that it is fixed in #920

pecko avatar Sep 28 '15 16:09 pecko

@dmarkov we are waiting for #1170

asaen avatar Oct 09 '15 14:10 asaen

@dmarkov we are waiting for #1170

@darkled yes, of course, we'll wait for #1170

dmarkov avatar Oct 13 '15 08:10 dmarkov

@rajithd please go ahead, it's your task now, keep this in mind, and don't hesitate to ask any technical questions you may have; The budget of this task is 30 mins. This is exactly how much time will be compensated, when the task is completed. Read about our Definition of Done

dmarkov avatar Jan 20 '16 11:01 dmarkov