PDA

View Full Version : Debug an app with weinre



huberte
14 Oct 2012, 11:30 AM
Finally,

it's almost there !

I used weinre to debug my app on my android phone : no pb with the web app

But if I packqge build with sencha cmd, app is not launching, weinre is not seeing the target.

I see that the script src with the weinre is still there in my apk, in index.html !
(Uh ? why is there an index.html in my apk, with development.js in it ? It should be production.js or something like that, right ?)

mitchellsimoens
16 Oct 2012, 6:47 AM
Are you using an IP to the weinre server and the server is listening on that IP?

huberte
16 Oct 2012, 5:39 PM
Yep ! It works with the app on localhost running on the emulator

I see the weinre client on my weinre server

It's not working with the app builded

EDIt; I'll be more specific, same happends with emulator or my smartphone : I can see my app when launching chrome on android : I can see the client connected on weinre. I can't see my app when launched as an apk : just the 3 dots blinking ; I can't see it in weinre.

huberte
24 Oct 2012, 4:22 PM
Sorry to ask again, but did someone succeed in debugging an apk (packed with sencha CMD) with weinre ?

I switch back to the test app "Welcome to sencha touch 2", even with this code, I see my client when launching the app via emulator's browser, not when launching the app in apk (which is hanging on the white dots)

Here the only thing I add to the code in index.html : the line 52 (and again, why is there development.js in my apk ? why is is not production.js ? or something else ?)


@-webkit-keyframes appLoadingIndicator{ 0% {
opacity: 0.8
}
50% {
opacity: 0
}
100% {
opacity: 0.8
}
}
</style>
<script src="http://192.168.0.10:8080/target/target-script-min.js#anonymous"></script>
<!-- The line below must be kept intact for Sencha Command to build your application -->
<script id="microloader" type="text/javascript" src="touch/microloader/development.js"></script>
</head>

EDIT :

The only thing shown in the console when using chrome on my smartphone is this :


[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.component' of: 'Ext.dataview.DataView' with: 'Ext.Component'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.mask' of: 'Ext.LoadMask' with: 'Ext.Mask'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.container' of: 'Ext.dataview.DataView' with: 'Ext.Container'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.viewport' of: 'Ext.viewport.Android' with: 'Ext.viewport.Default'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.component' of: 'Ext.dataview.DataView' with: 'Ext.Component'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.mask' of: 'Ext.LoadMask' with: 'Ext.Mask'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.container' of: 'Ext.dataview.DataView' with: 'Ext.Container'. Be sure it's intentional.
[INFO] [Ext.ClassManager] Overriding existing alias: 'widget.viewport' of: 'Ext.viewport.Android' with: 'Ext.viewport.Default'. Be sure it's intentional.

When packed, the app wont launch, weinre shows nothing

debianw
29 Oct 2012, 7:04 AM
Try to add the script inside the app.json.

What I've been doing inside my app is adding a way to turn on/off the remote debugging. Example I have a togglefield in my configuration screen and I am listening the dragend event of that field and in my controller I load the script at runtime.



var bodyEl = document.getElementsByTagName('body')[0],
scriptDebugJS;


// create script element
scriptDebugJS = document.createElement('script');
scriptDebugJS.type = "text/javascript";
scriptDebugJS.src = "http://ip_address_of_server:3000/target/target-script-min.js#anonymous";
scriptDebugJS.id = "scriptDebugJS";


bodyEl.appendChild(scriptDebugJS);


I don't have any problem with that for now.


I'm still looking a way to turn off the debugger. Removing the script at runtime does not stop the connection to the weinre server.

huberte
17 Nov 2012, 10:43 PM
Could you tell me how do I add an easy line for weinre in app.json please ?

mitchellsimoens
18 Nov 2012, 6:11 AM
For development you can add the url as an entry in the js array. When you build this will try to copy the file depending on which version you are using. You may just have to edit the index.html in that case.

huberte
18 Nov 2012, 10:23 AM
Did you read the thread ? I wrote about the fact that weinre does no see the client in apk, when added to index.html.

http://www.sencha.com/forum/showthread.php?245969-Debug-an-app-with-weinre&p=903633&viewfull=1#post903633

SO could you be more specific and tell me exactly where to put
http://192.168.0.10:8080/target/target-script-min.js#anonymous

You can sse this other thread too : http://www.sencha.com/forum/showthread.php?249358-Unable-to-run-apk&p=912764#post912764