Hyperloop titanium Error: Requested module not found - titanium

I make the setup as given in the documentation and always get the following error message: "Error: Requested module not found: android.app.Activity", how to solve this ?
function doClick(e) {
alert($.label.text);
}
var Activity = require('android.app.Activity');
var ac = new Activity();
$.index.open();

If you're working with LiveView - disable LiveView and clean your project. That was the case for me on Android.

I'm using this code to get the Android activities (i.e. open, pause, resume, stop etc..):
var activity = Ti.Android.currentActivity;
But in your situation, you probably need to use this:
var Activity = require('android.app.Activity');
var ac = new Activity(Ti.Android.currentActivity)

Make sure hyperloop module is available in your tiapp.xml file modules section.
<modules>
<module platform="android">hyperloop</module>
<module platform="iphone">hyperloop</module>
</modules>
Please see the following doc links
- http://docs.appcelerator.com/platform/latest/#!/guide/Enabling_Hyperloop
- http://docs.appcelerator.com/platform/latest/#!/guide/Hyperloop_Guides
Hope this helps.

Related

Flow saying "Required module not found" for <Image> sources

We have an existing React Native project (version 0.22.2) and I'm trying to set up the Flow type checker (version 0.23) on certain files. However, Flow is giving a lot of errors for the require()s calls we're using for <Image> sources. For example, we have this code in one of our components in Header.js:
<Image source={require('./images/nav.png')} style={styles.navIcon} />
Which React Native handles fine and it works. However, Flow seems to be trying to treat the require() as a regular module require and not finding it, and giving errors like this:
Header.js:30
30: <Image source={require('./images/nav.png')} style={styles.navIcon} />
^^^^^^^^^^^^^^^^^^^^^^^^^^^ ./images/nav.png. Required module not found
How can I tell Flow to stop giving these errors? I've tried adding .*/images/.* to the [ignore] section of my .flowconfig, but that doesn't change anything.
You can use the module.name_mapper.extension option in .flowconfig. For example,
[options]
module.name_mapper.extension= 'png' -> '<PROJECT_ROOT>/ImageSourceStub.js.flow'
which will map any module name ending in .png to an ImageSourceStub module, as if instead of writing require('./foo.png') you had written require('./path/to/root/ImageSourceStub').
In ImageSourceStub.js.flow you can do
const stub = {
uri: 'stub.png'
};
export default stub; // or module.exports = stub;
so that Flow knows that require('*.png') returns a {uri: string}.
See also the Advanced Configuration docs.
I don't have a real answer besides to say that flow in React Native seems really dodgy today and it would not surprise me if flow just simply doesn't support this usage at all, but I'd love to be totally surprised!
Personally, as a work-around, I'd just add a higher level component and ignore the flow errors in that file.
// Picture.js
// (No #flow tag at top of file)
const Picture = ({ source }) => (
<Image source={require(source)} />
)
Then use <Picture source="my/path/pic.jpg" /> instead.
Had same issue, for JPG files, solved with this .flowconfig
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.jpg$' -> 'RelativeImageStub'

how to open a url in ios child browser using Titanium?

Can any one please let me know how to open child browser using titanium for IOS.
I have used, Titanium.Platform.openURL(url); but it is opening out of the application and can't come back to our app after closing the window/tab.Any ideas?
Thanks in Advance,
Swathi
You can use a WebView for that. Have a look at the API:
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.WebView
there is an example how to use it.
I think what you're looking for is a SafariDialog described here:
http://docs.appcelerator.com/platform/latest/#!/api/Modules.SafariDialog
Add the module like so:
<ti:app>
...
<modules>
<module platform="iphone">ti.safaridialog</module>
</modules>
...
</ti:app>
And use it like so:
var dialog = require('ti.safaridialog');
if (dialog.isSupported()) {
dialog.open({
url: 'http://appcelerator.com',
title: 'Titanium rocks!',
tintColor: 'red'
});
}
This also adds the "Done" button you were looking for.

Dojo cache issue

I am using dojo i18n:
dojo.requireLocalization("scripts", "scprop");
var nls = dojo.i18n.getLocalization("scripts", "scprop");
to get text from nls.keyname and it is working fine.
When resource bundle changed (adding/removing keys), new bundle is not loading - still loading old bundle from cache. How to reload the new bundle. Please suggest.
I modified the dojo source code to fix this. This was done on the 1.8.x codebase. Not sure what the 1.9.x codebase looks like.
dojo/i18n.js ~line 444
// MODIFIED: append a query parameter to handle caching of
// modules/resource bundles by product version
var modUrl = url + '?dojo.cache=' +
encodeURIComponent(dojo.config.loadURIVersion || dojo.version.revision);
// ****************************************************************************
xhr.get({
url:modUrl, // MODIFIED
sync:true,
load:load,
error:function(){
results.push(cache[url] = {});
}
});

Air - How to use a native extension in Flash CS5.5?

I would like to use a native extension (ANE) in Flash CS5.5. I saved the ANE as a SWC and added it to my project, but this error keeps on coming up:
Error message:
1172: Definition qnx.events:InvokeEvent could not be found.
ActionScript:
import qnx.events.InvokeEvent;
import qnx.invoke.*;
//NOTE: THIS MUST BE THE FIRST THING SET IN YOUR APPLICATION CONSTRUCTOR
InvokeManager.invokeManager.addEventListener(InvokeEvent.INVOKE, onInvoke );
function onInvoke( event:InvokeEvent ):void
{
if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE )
{
//invoked as an application/target.
var mydata:InvokeRequest = InvokeManager.invokeManager.startupRequest;
}
else if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.VIEWER )
{
//invoked as a viewer
var myotherdata:InvokeViewerRequest = InvokeManager.invokeManager.startupViewerRequest;
}
else
{
//launched by the pressing on the icon on the home screen.
}
}
Is there anything missing in the code?
I never used an ANE/SWC before, so any help is welcome.
I uploaded the files. Would be great if someone could take a look at them:
Download: http://www.sendspace.com/file/gjqp1w
Thanks.
How are you packaging the application? This error generally means the extension is not being packaged correctly with the application.
I believe from CS5.5 you still have to use the adt command line to specify the location of the ANE file when packaging, so if you're just exporting from CS5.5 you'll get this error.
Something like the following:
adt -package
-target ipa-ad-hoc
-storetype pkcs12 -keystore ../AppleDistribution.p12
-provisioning-profile AppleDistribution.mobileprofile
myApp.ipa
myApp-app.xml
myApp.swf icons Default.png
-extdir extensionsDir
Additionally you have to make sure you add the extensions id to you application descriptor:
<extensions>
<extensionID>com.extension.id</extensionID>
</extensions>

Error with required module, argument size must be >= 0

I am developing a mobile application using Appcelerator and am including some configuration functions using commonJS.
The code that I am running is as follows:
app.js
var well = {};
well.config = require('config');
config.js
var configJson = JSON.parse(Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'config.json'));
exports.getFeed = function(_feed){
return configJson.feeds.sermon[_feed];
};
When I try to run the code, I get the following error:
Location:
[3,0] file:///android_asset/Resources/app.js
Wrapped java.lang.IllegalArgumentException: size must be >= 0 (file:///android_asset/Resources/app.js#3)
Am I doing something wrong to include the module?
you need to turn off fastdev and it will work fine, add this to yout tiapp.xml
<property name="ti.android.fastdev" type="bool">false</property>
<property name="ti.android.compilejs" type="bool">true</property>
I am using 1.7.2 and it is running fine on android