Issue
When an app is installed on certain Android OS versions, that may create couple of instances by instance I mean an app icon. Meanwhile one of them is able to run, the other just fails. We couldn't get customer's source but that can be replicated using the Kitchen Sink demo which is available below.
Steps to reproduce
1. Get Kitchen Sink app from
http://dl.dropbox.com/u/34061091/KitchenSInk1.zip
2. Use "Install to Android Device" option from Studio IDE
3. At device goto "All apps" and launch KitchenSink. From there, couple icons can be seen (at the top left on my device's screen shoot).
Console outputs
Console output: Clicking on 1st app icon
The app is unable to run, fails throwing the following runtime error:
04-03 11:00:03.531: I/ActivityManager(500): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.appcelerator.kitchensink/.KitchensinkActivity } from pid 863
04-03 11:00:03.625: D/ActivityRenderTarget(863): onPause
04-03 11:00:03.648: I/gralloc(500): Allocated 0x73756170 size 1715299429
04-03 11:00:03.726: E/dalvikvm(27928): could not disable core file generation for pid 27928: Operation not permitted
04-03 11:00:03.726: I/ActivityManager(500): Start proc com.appcelerator.kitchensink for activity com.appcelerator.kitchensink/.KitchensinkActivity: pid=27928 uid=10058 gids={1015, 1006, 3003}
04-03 11:00:03.765: D/dalvikvm(27928): Debugger has detached; object registry had 1 entries
04-03 11:00:03.859: I/TiApplication(27928): (main) [0,0] checkpoint, app created.
04-03 11:00:04.070: D/dalvikvm(27928): GC_CONCURRENT freed 950K, 43% free 4103K/7175K, external 2357K/2773K, paused 1ms+2ms
04-03 11:00:04.085: I/TiApplication(27928): (main) [227,227] Titanium 3.0.0 (2012/12/12 18:49 a5894b3)
04-03 11:00:04.132: D/dalvikvm(27928): Trying to load lib /data/data/com.appcelerator.kitchensink/lib/libstlport_shared.so 0x4051b9c8
04-03 11:00:04.132: I/TiApplication(27928): (main) [47,274] Titanium Javascript runtime: v8
04-03 11:00:04.140: D/dalvikvm(27928): Added shared lib /data/data/com.appcelerator.kitchensink/lib/libstlport_shared.so 0x4051b9c8
04-03 11:00:04.140: D/dalvikvm(27928): No JNI_OnLoad found in /data/data/com.appcelerator.kitchensink/lib/libstlport_shared.so 0x4051b9c8, skipping init
04-03 11:00:04.140: D/dalvikvm(27928): Trying to load lib /data/data/com.appcelerator.kitchensink/lib/libkroll-v8.so 0x4051b9c8
04-03 11:00:04.140: D/AndroidRuntime(27928): Shutting down VM
04-03 11:00:04.140: W/dalvikvm(27928): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
04-03 11:00:04.140: D/dalvikvm(27928): Added shared lib /data/data/com.appcelerator.kitchensink/lib/libkroll-v8.so 0x4051b9c8
04-03 11:00:04.148: E/TiApplication(27928): (main) [8,282] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appcelerator.kitchensink/com.appcelerator.kitchensink.KitchensinkActivity}: java.lang.ClassNotFoundException: com.appcelerator.kitchensink.KitchensinkActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.appcelerator.kitchensink-1.apk]; Titanium 3.0.0,2012/12/12 18:49,a5894b3
04-03 11:00:04.148: E/TiApplication(27928): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appcelerator.kitchensink/com.appcelerator.kitchensink.KitchensinkActivity}: java.lang.ClassNotFoundException: com.appcelerator.kitchensink.KitchensinkActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.appcelerator.kitchensink-1.apk]
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1727)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread.access$1500(ActivityThread.java:124)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
04-03 11:00:04.148: E/TiApplication(27928): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 11:00:04.148: E/TiApplication(27928): at android.os.Looper.loop(Looper.java:130)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread.main(ActivityThread.java:3859)
04-03 11:00:04.148: E/TiApplication(27928): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 11:00:04.148: E/TiApplication(27928): at java.lang.reflect.Method.invoke(Method.java:507)
04-03 11:00:04.148: E/TiApplication(27928): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:840)
04-03 11:00:04.148: E/TiApplication(27928): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:598)
04-03 11:00:04.148: E/TiApplication(27928): at dalvik.system.NativeStart.main(Native Method)
04-03 11:00:04.148: E/TiApplication(27928): Caused by: java.lang.ClassNotFoundException: com.appcelerator.kitchensink.KitchensinkActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.appcelerator.kitchensink-1.apk]
04-03 11:00:04.148: E/TiApplication(27928): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
04-03 11:00:04.148: E/TiApplication(27928): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
04-03 11:00:04.148: E/TiApplication(27928): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-03 11:00:04.148: E/TiApplication(27928): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1616)
04-03 11:00:04.148: E/TiApplication(27928): ... 11 more
04-03 11:00:04.289: E/TiApplication(27928): (KrollRuntimeThread) [146,428] APP PROXY: ti.modules.titanium.app.AppModule@405bc468
04-03 11:00:04.304: W/V8Object(27928): Runtime disposed, cannot set property 'userAgent'
04-03 11:00:12.085: E/TiHttpClient(26375): (TiHttpClient-3) [19634,23397] HTTP Error (org.apache.http.conn.ConnectTimeoutException): Connect to /10.60.201.166:8080 timed out
04-03 11:00:12.085: E/TiHttpClient(26375): org.apache.http.conn.ConnectTimeoutException: Connect to /10.60.201.166:8080 timed out
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:147)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:363)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:653)
04-03 11:00:12.085: E/TiHttpClient(26375): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
04-03 11:00:12.085: E/TiHttpClient(26375): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1186)
04-03 11:00:12.085: E/TiHttpClient(26375): at java.lang.Thread.run(Thread.java:1019)
04-03 11:00:12.085: I/TiHttpClient(26375): (TiHttpClient-3) [3,23400] Sending error Connect to /10.60.201.166:8080 timed out
04-03 11:00:12.085: W/V8Function(26375): Runtime disposed, cannot call function.
Console output: Clicking on 2nd app icon
The app launches as expected
04-03 11:45:49.992: I/ActivityManager(500): Starting: Intent { cmp=com.appcelerator.kitchensink/org.appcelerator.titanium.TiActivity (has extras) } from pid 30051
04-03 11:45:50.000: D/Module(30051): Loading module: ui/common/MessageWindow -> Resources/ui/common/MessageWindow.js
04-03 11:45:50.039: I/TiAPI(30051): Welcome to Kitchen Sink for Titanium/3.0.0
04-03 11:45:50.039: D/TiAPI(30051): user agent set to Dalvik/1.4.0 (Linux; U; Android 2.3.5; DROID RAZR Build/6.5.1-73_DHD-11_M1-2) Titanium/3.0.0
04-03 11:45:50.039: D/TiAPI(30051): locale specific date is 4/3/13
04-03 11:45:50.046: D/TiAPI(30051): locale specific date (medium) is Apr 3, 2013
04-03 11:45:50.046: D/TiAPI(30051): locale specific date (long) is April 3, 2013
04-03 11:45:50.046: D/TiAPI(30051): locale specific time is 11:45 AM
04-03 11:45:50.054: D/TiAPI(30051): locale specific currency is $12.99
04-03 11:45:50.062: D/TiAPI(30051): locale specific decimal is 12.99
04-03 11:45:50.062: I/TiAPI(30051): should be en, was = en
04-03 11:45:50.062: I/TiAPI(30051): welcome_message = Welcome to Kitchen Sink for Titanium/
04-03 11:45:50.070: I/TiAPI(30051): should be def, was = def
Additional details
Customer have found an issue in the appname they were providing via tiapp.xml. If this name starts with a digit [0-9], there is logic in the Ti android.py script to prepend the appname with an underscore '_' character. This results in multiple intents begin added to the manifest file and potentially the cause of this issue.
@classmethod
def strip_classname(cls, name):
classname = ''.join([str.capitalize() for str in re.split('[^A-Za-z0-9_]', name)])
if re.search("^[0-9]", classname) != None:
classname = "_" + classname
return classname
This isn't really a bug, it's expected behavior. Inside the tiapp.xml, you specify an activity called KitchensinkActivity, a label called KitchenSink and added the category launcher to it. That's basically telling android to create a new icon in the launcher drawer named KitchenSink, and have it load an activity called KitchensinkActivity, which will not exist. I'm not really sure what the app is trying to do here, but if you want to create a secondary icon that launches KitchenSink correctly, you just need to specify the activity name to be the same as the one that titanium generates, which is Kitchensink214gaActivity.
I've tried out suggestions above but I'm still seeing couple app icons. After removing
Similar discussion: http://stackoverflow.com/questions/8697943/android-application-creating-two-launcher-icons
Closing as invalid.