Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24022] Hyperloop: Android: Unable to instantiate hyperloop classes

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-10-12T21:12:34.000+0000
Affected Version/sHyperloop 2.0.0
Fix Version/sRelease 6.0.0, Hyperloop 2.0.0
ComponentsAndroid, Hyperloop
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2016-10-12T20:00:33.000+0000
Updated2016-10-25T01:19:51.000+0000

Description

When attempting to instantiate a native class in JS, we end up with a class cast exception about casting a String to Integer.

Attachments

FileDateSize
Screen Shot 2016-10-12 at 3.59.13 PM.png2016-10-12T19:59:25.000+0000191580

Comments

  1. Christopher Williams 2016-10-12

    This is a result of a behavior change due to the fix for TIMOB-23966. We now force JS objects to turn into Map going across the bridge. Before it would auto-convert a key like '1' to an actual Integer on the Java side, which broke analytics. Hyperloop relied on this broken conversion when receiving an array of arguments and assumed we'd get Map. We no longer do, so I need to handle Map instead.
  2. Christopher Williams 2016-10-12

    To test, try this as your app.js in a hyperloop project:
       var Intent = require('android.content.Intent');
       var Activity = require('android.app.Activity');
       var Uri = require("android.net.Uri");
       
       var win = Ti.UI.createWindow({
           backgroundColor: "#fff"
       });
       
       var btn = Ti.UI.createButton({
           title: "Trigger"
       });
       
       btn.addEventListener("click", openIntent);
       
       win.add(btn);
       win.open();
       
       function openIntent() {
           var activity = new Activity(Ti.Android.currentActivity);
       
           var intent = Ti.Android.createIntent({
               action: Ti.Android.ACTION_VIEW
           });
       
           var nativeIntent = new Intent(intent);
           nativeIntent.setData(Uri.parse("sms://"));
           nativeIntent.putExtra("sms_body", "Hello world!");
       
           activity.startActivity(nativeIntent);
       }
       
       
  3. Christopher Williams 2016-10-12

    PR (master): https://github.com/appcelerator/hyperloop.next/pull/86 PR (2_0_X): https://github.com/appcelerator/hyperloop.next/pull/85
  4. Lokesh Choudhary 2016-10-25

    Verified the fix. Hyperloop classes can be instantiated successfully. Closing. Appc Studio : 4.8.0.201610171310 SDK Version : 6.0.0.v20161024145110 Mac OS Version : 10.11.6 Xcode Version : Xcode 8.0 Build version 8A218a Appc CLI AND Appc NPM : {"NPM":"4.2.8-9","CLI":"6.0.0-64"} Ti CLI : 5.0.10 Alloy : 1.9.3 Node : v4.6.0 Hyperloop: 2.0.0 Beta 4

JSON Source