Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23933] Hyperloop - Android: JS Wrappers not being generated for org.json .JAR

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-01-31T19:45:26.000+0000
Affected Version/sn/a
Fix Version/sHyperloop 3.0.2
ComponentsHyperloop
Labelsandroid, hyperloop, json
ReporterRodolfo Perottoni
AssigneeJan Vennemann
Created2016-09-16T00:47:18.000+0000
Updated2018-02-05T16:53:27.000+0000

Description

I'm trying to import the lib *org.json* into a Hyperloop project by placing it inside *app/platform/android*. The lib is contained inside a *jar* file. I'm building my project and somehow the JS wrappers for this lib are not being generated. At first I thought jars were not supported, but then I saw that the Hyperloop examples project is using a *.jar* (volley.jar) without any problems. I've attached the .jar with the mentioned lib so you can try and reproduce the same error.

Attachments

FileDateSize
json.jar2016-09-21T04:01:09.000+000084697

Comments

  1. Hans Knöchel 2016-09-17

    We cannot work with this ticket at this moment. Please provide: - full trace-log - reproducible example-code - related jar-file
  2. Rodolfo Perottoni 2016-09-21

    Hey Hans. Sorry for the bad description. I must've had a bad day when I wrote this ticket and didn't notice how poorly described it was. * Full trace log is not necessary in this case - there is no error. * Jar file is attached. Example will be provided in the next comment.
  3. Rodolfo Perottoni 2016-09-21

       var OAuth = require('io.oauth.OAuth'),
             OAuthCallback = require('io.oauth.OAuthCallback'),
             Activity = require('android.app.Activity'),
             OAuthJSONCallback = require('io.oauth.http.OAuthJSONCallback'),
             callbackOauth, oauth;
       
       $.getView().activity.onResume = function() {
           oauth = new Activity($.getView().activity);
           oauth.initialize('BOYep66tMyWO46oe5Q7B8l9odaQ');
       
           callbackOauth = new OAuthCallback({
               onFinished: function(data) {
                   if (data.status == "error") {
                       alert('oops');
                   } else {
                       // Retrieves the user informations
                       var callback = OAuthJSONCallback.extend({
                           onFinished: function(me) {
                               Ti.API.error(me);
                           },
                           onError: function(message) {
                               Ti.API.error(message);
                           }
                       });
       
                       data.me(new callback());
                   }
               }
           });
       
           oauth.popup("google", callbackOauth);
       
       }
       
       
       
  4. Brian García 2016-11-22

    It fails also with SDK 6.0.0 and Hyperloop 2.0. Requiring
       ('org.json.JSONObject') 
       
    does not generate the proper files
  5. Hans Knöchel 2016-12-12

    [~gmathews] I just noticed that we have [this line](https://github.com/garymathews/hyperloop.next/blob/c704f700041b3ea665188c86cf681774320e67d7/android/plugins/hyperloop/hooks/android/metabase/metabase.js#L75) in our metabase. Could that be something hardcoded that prevents us from adding the json.jar manually?
  6. Brian García 2016-12-13

    Hi, for me, replacing line 66 in JavaMetabaseGenerator.java with this:
       if (((filename.endsWith("android.jar")/* && whitelist.matcher(entry).find()*/) || true)/* && !blacklist.matcher(entry).find() */&& isClass.matcher(entry).find())
       
    does the trick and the bindings for json.jar are generated.
  7. Jan Vennemann 2018-01-24

    PR: https://github.com/appcelerator/hyperloop.next/pull/268
  8. Jan Vennemann 2018-02-02

    [~lchoudhary], follow these steps to validate this ticket:

    Place the attached json.jar under platform/android

    Add the following code to use the JSON library:

       var JSONObject = require('org.json.JSONObject');
       var data = new JSONObject();
       data.put('foo', 'bar');
       data.put('solution', 42);
       console.log('JSON string: ' + data.toString());
       

    Run the app

    *Expected behavior* The build succeeds and the app starts without any errors. The following string should be printed to the logs:
       [INFO]  JSON string: {"foo":"bar","solution":42}
       
  9. Lokesh Choudhary 2018-02-05

    Verified the fix with hyperloop 3.0.2. Closing. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.0.2.v20180201155017 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.2-master.7 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.12 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 5 --- Android 6.0.1 ⇨ google Pixel --- Android 7.1.1

JSON Source