<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>16</tool-api-level>
<manifest android:installLocation="preferExternal">
<supports-screens android:anyDensity="false"/>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"/>
</manifest>
</android>
App crashes when setting a remote URL for the ActionBar logo, backgroundImage, or icon. See code below.
index.xml:
<Alloy>
<Window id="myWin" class="container" navBarHidden="false">
</Window>
</Alloy>
index.js:
$.myWin.addEventListener('open', function() {
if (Ti.Platform.name === 'android') {
var act = $.myWin.activity;
if (!act) {
alert("Can't access action bar on a lightweight window.");
} else {
var actionBar = act.actionBar;
if (actionBar){
//These work fine, it's the same image as in URL
//actionBar.setLogo('/images/smallpic.jpg');
//actionBar.setIcon('/images/smallpic.jpg');
//actionBar.setBackgroundImage('/images/smallpic.jpg');
//Any of the below crash the app
actionBar.setLogo('https://graph.facebook.com/shaverm/picture');
//actionBar.setBackgroundImage('https://graph.facebook.com/shaverm/picture');
//actionBar.setIcon('https://graph.facebook.com/shaverm/picture');
}
}
}
});
$.myWin.open();
Copy and pasted code into respective folders. Do not see an actionbar or evidence of crashing. Using Galaxy s3 4.1.2. Can you please provide a more thorough set of steps to reproduce and any other information that may be missing? For reference: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report Thanks, Carter
Can you paste your tiapp.xml here? It should contain the XML I showed above. On ICS, unless you're explicitly hiding the action bar (e.g. navBarHidden = true) it should appear. So I would assume the issue is with your tiapp.xml or your tool setup. I tested with API 16 tools, as shown by the XML.
Carter, this likely better assigned to the platform team as it appears it is not directly related to Alloy.
Mark, are you testing this on ICS or on Jellybean? Here is my xml
let me know if I have everything you do. CarterHi Carter, My environment is as specified above - 3.0.2, Nexus S, Android 4.1.2 I took your XML verbatim (except my Studio complained about the tizen line), I pasted the code from above into index.xml and index.js. It crashes with setLogo (and the other functions too) for URL images, fine with file images (same image in all cases). It's a network request on main thread, here's the crash log:
04-04 01:35:29.789: D/dalvikvm(1197): GC_CONCURRENT freed 1396K, 12% free 11541K/12999K, paused 17ms+5ms, total 84ms 04-04 01:35:29.789: D/dalvikvm(1197): WAIT_FOR_CONCURRENT_GC blocked 22ms 04-04 01:35:29.887: D/Finsky(1197): [1] 5.onFinished: Installation state replication succeeded. 04-04 01:35:31.191: I/ActivityManager(248): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.appcelerator.alloytester/.AlloytesterActivity u=0} from pid 466 04-04 01:35:31.285: D/dalvikvm(248): GC_FOR_ALLOC freed 623K, 38% free 15122K/24199K, paused 67ms, total 70ms 04-04 01:35:31.340: I/ActivityManager(248): Start proc com.appcelerator.alloytester for activity com.appcelerator.alloytester/.AlloytesterActivity: pid=3192 uid=10089 gids={1015, 3003, 1028} 04-04 01:35:31.484: I/TiApplication(3192): (main) [0,0] checkpoint, app created. 04-04 01:35:31.562: D/dalvikvm(248): GC_CONCURRENT freed 49K, 31% free 16810K/24199K, paused 25ms+10ms, total 274ms 04-04 01:35:31.609: I/TiApplication(3192): (main) [125,125] Titanium 3.0.2 (2013/02/15 19:02 5a77fe7) 04-04 01:35:31.664: D/dalvikvm(3192): GC_CONCURRENT freed 274K, 4% free 8195K/8519K, paused 18ms+2ms, total 44ms 04-04 01:35:31.664: D/dalvikvm(3192): WAIT_FOR_CONCURRENT_GC blocked 25ms 04-04 01:35:31.668: D/dalvikvm(3192): WAIT_FOR_CONCURRENT_GC blocked 24ms 04-04 01:35:31.809: I/TiApplication(3192): (main) [198,323] Titanium Javascript runtime: v8 04-04 01:35:31.820: D/dalvikvm(3192): Trying to load lib /mnt/asec/com.appcelerator.alloytester-1/lib/libstlport_shared.so 0x4184b1a8 04-04 01:35:31.863: D/dalvikvm(3192): Added shared lib /mnt/asec/com.appcelerator.alloytester-1/lib/libstlport_shared.so 0x4184b1a8 04-04 01:35:31.863: D/dalvikvm(3192): No JNI_OnLoad found in /mnt/asec/com.appcelerator.alloytester-1/lib/libstlport_shared.so 0x4184b1a8, skipping init 04-04 01:35:31.867: D/dalvikvm(3192): Trying to load lib /mnt/asec/com.appcelerator.alloytester-1/lib/libkroll-v8.so 0x4184b1a8 04-04 01:35:31.969: I/TiRootActivity(3192): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null 04-04 01:35:32.117: D/dalvikvm(3192): Added shared lib /mnt/asec/com.appcelerator.alloytester-1/lib/libkroll-v8.so 0x4184b1a8 04-04 01:35:32.551: E/TiApplication(3192): (KrollRuntimeThread) [584,584] APP PROXY: ti.modules.titanium.app.AppModule@418c0350 04-04 01:35:32.641: D/Module(3192): Loading module: alloy -> Resources/alloy.js 04-04 01:35:32.656: D/Module(3192): Loading module: alloy/underscore -> Resources/alloy/underscore.js 04-04 01:35:32.695: D/dalvikvm(3192): GC_CONCURRENT freed 394K, 6% free 8289K/8775K, paused 12ms+2ms, total 33ms 04-04 01:35:32.695: D/dalvikvm(3192): WAIT_FOR_CONCURRENT_GC blocked 14ms 04-04 01:35:32.809: D/Module(3192): Loading module: alloy/backbone -> Resources/alloy/backbone.js 04-04 01:35:32.832: D/dalvikvm(3192): GC_FOR_ALLOC freed 208K, 7% free 8282K/8839K, paused 22ms, total 23ms 04-04 01:35:32.898: D/Module(3192): Loading module: alloy/CFG -> Resources/alloy/CFG.js 04-04 01:35:32.902: D/Module(3192): Loading module: alloy/controllers/index -> Resources/alloy/controllers/index.js 04-04 01:35:32.914: D/Module(3192): Loading module: alloy/controllers/BaseController -> Resources/alloy/controllers/BaseController.js 04-04 01:35:32.937: I/ActivityManager(248): START {cmp=com.appcelerator.alloytester/org.appcelerator.titanium.TiActivity (has extras) u=0} from pid 3192 04-04 01:35:33.000: D/dalvikvm(3192): GC_FOR_ALLOC freed 234K, 7% free 8265K/8839K, paused 21ms, total 22ms 04-04 01:35:33.004: I/dalvikvm-heap(3192): Grow heap (frag case) to 9.583MB for 1536016-byte allocation 04-04 01:35:33.047: D/dalvikvm(3192): GC_CONCURRENT freed 2K, 6% free 9762K/10375K, paused 12ms+4ms, total 42ms 04-04 01:35:33.105: D/dalvikvm(3192): GC_FOR_ALLOC freed 0K, 6% free 9762K/10375K, paused 15ms, total 15ms 04-04 01:35:33.105: I/dalvikvm-heap(3192): Grow heap (frag case) to 10.231MB for 682256-byte allocation 04-04 01:35:33.144: D/dalvikvm(3192): GC_CONCURRENT freed 0K, 6% free 10429K/11079K, paused 12ms+5ms, total 38ms 04-04 01:35:33.164: D/dalvikvm(3192): Trying to load lib /mnt/asec/com.appcelerator.alloytester-1/lib/libtiverify.so 0x4184b1a8 04-04 01:35:33.164: D/dalvikvm(3192): Added shared lib /mnt/asec/com.appcelerator.alloytester-1/lib/libtiverify.so 0x4184b1a8 04-04 01:35:33.168: I/TiRootActivity(3192): (main) [0,0] checkpoint, on root activity resume. activity = com.appcelerator.alloytester.AlloytesterActivity@4188bb08 04-04 01:35:33.289: D/AndroidRuntime(3192): Shutting down VM 04-04 01:35:33.289: W/dalvikvm(3192): threadid=1: thread exiting with uncaught exception (group=0x4107a300) 04-04 01:35:33.312: E/TiApplication(3192): (main) [122,122] Sending event: exception on thread: main msg:android.os.NetworkOnMainThreadException; Titanium 3.0.2,2013/02/15 19:02,5a77fe7 04-04 01:35:33.312: E/TiApplication(3192): android.os.NetworkOnMainThreadException 04-04 01:35:33.312: E/TiApplication(3192): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) 04-04 01:35:33.312: E/TiApplication(3192): at java.net.InetAddress.lookupHostByName(InetAddress.java:385) 04-04 01:35:33.312: E/TiApplication(3192): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 04-04 01:35:33.312: E/TiApplication(3192): at java.net.InetAddress.getAllByName(InetAddress.java:214) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168) 04-04 01:35:33.312: E/TiApplication(3192): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271) 04-04 01:35:33.312: E/TiApplication(3192): at java.net.URL.openStream(URL.java:462) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.util.TiFileHelper.openInputStream(TiFileHelper.java:176) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:308) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:262) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.getDrawableFromUrl(ActionBarProxy.java:193) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetLogo(ActionBarProxy.java:183) 04-04 01:35:33.312: E/TiApplication(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:216) 04-04 01:35:33.312: E/TiApplication(3192): at android.os.Handler.dispatchMessage(Handler.java:95) 04-04 01:35:33.312: E/TiApplication(3192): at android.os.Looper.loop(Looper.java:137) 04-04 01:35:33.312: E/TiApplication(3192): at android.app.ActivityThread.main(ActivityThread.java:4745) 04-04 01:35:33.312: E/TiApplication(3192): at java.lang.reflect.Method.invokeNative(Native Method) 04-04 01:35:33.312: E/TiApplication(3192): at java.lang.reflect.Method.invoke(Method.java:511) 04-04 01:35:33.312: E/TiApplication(3192): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 04-04 01:35:33.312: E/TiApplication(3192): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 04-04 01:35:33.312: E/TiApplication(3192): at dalvik.system.NativeStart.main(Native Method) 04-04 01:35:33.336: E/AndroidRuntime(3192): FATAL EXCEPTION: main 04-04 01:35:33.336: E/AndroidRuntime(3192): android.os.NetworkOnMainThreadException 04-04 01:35:33.336: E/AndroidRuntime(3192): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.net.InetAddress.lookupHostByName(InetAddress.java:385) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.net.InetAddress.getAllByName(InetAddress.java:214) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168) 04-04 01:35:33.336: E/AndroidRuntime(3192): at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.net.URL.openStream(URL.java:462) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.util.TiFileHelper.openInputStream(TiFileHelper.java:176) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:308) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:262) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.getDrawableFromUrl(ActionBarProxy.java:193) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.handleSetLogo(ActionBarProxy.java:183) 04-04 01:35:33.336: E/AndroidRuntime(3192): at org.appcelerator.titanium.proxy.ActionBarProxy.handleMessage(ActionBarProxy.java:216) 04-04 01:35:33.336: E/AndroidRuntime(3192): at android.os.Handler.dispatchMessage(Handler.java:95) 04-04 01:35:33.336: E/AndroidRuntime(3192): at android.os.Looper.loop(Looper.java:137) 04-04 01:35:33.336: E/AndroidRuntime(3192): at android.app.ActivityThread.main(ActivityThread.java:4745) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.lang.reflect.Method.invokeNative(Native Method) 04-04 01:35:33.336: E/AndroidRuntime(3192): at java.lang.reflect.Method.invoke(Method.java:511) 04-04 01:35:33.336: E/AndroidRuntime(3192): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 04-04 01:35:33.336: E/AndroidRuntime(3192): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 04-04 01:35:33.336: E/AndroidRuntime(3192): at dalvik.system.NativeStart.main(Native Method) 04-04 01:35:33.340: W/ActivityManager(248): Force finishing activity com.appcelerator.alloytester/org.appcelerator.titanium.TiActivity 04-04 01:35:33.371: W/ActivityManager(248): Force finishing activity com.appcelerator.alloytester/.AlloytesterActivity 04-04 01:35:33.871: W/ActivityManager(248): Activity pause timeout for ActivityRecord{41a7c5b8 com.appcelerator.alloytester/org.appcelerator.titanium.TiActivity} 04-04 01:35:34.125: I/ActivityManager(248): No longer want com.android.keychain (pid 3163): hidden #16 04-04 01:35:44.125: W/ActivityManager(248): Activity destroy timeout for ActivityRecord{41e6f130 com.appcelerator.alloytester/.AlloytesterActivity} 04-04 01:35:44.125: W/ActivityManager(248): Activity destroy timeout for ActivityRecord{41a7c5b8 com.appcelerator.alloytester/org.appcelerator.titanium.TiActivity} : E/(): Device disconnectedMark, Would you mind providing a couple screenshots. One of the working actionbar and one of the crashing instance? Then I will move to Ti-Mobile. Thanks for your patience, Carter
Screen shots attached. Again - the only difference is
(fine) versusactionBar.setLogo('/images/smallpic.jpg')(crash). The image is the same. Tiapp.xml is the copy you sent, verbatim except Tizen line.actionBar.setLogo('https://graph.facebook.com/shaverm/picture');Is it possible to try this again on 3.1.0? I'm assuming no difference, but it would be helpful to confirm.
Mark, After talking this over with engineering, I realized that it is not recommended to use a remote image location for a logo or icon within an action bar. It is only really acceptable to use a remote image when loading it into a imageview first. In order to achieve the same effect as an actionbar you can put this imageview into a custom view that acts and looks like an actionbar. Any questions or comments feel free to ask. Regards, Carter
I agree with this, but please update the docs to remove the URL option for Action Bar icon, logo, backgroundImage. And yes, it crashes with 3.1.0 beta release.