could not encode class bundle

The place to discuss anything and everything about running your LiveCode on Android

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
paulrichards999
Posts: 18
Joined: Thu Sep 04, 2014 3:32 pm

could not encode class bundle

Post by paulrichards999 » Wed Dec 14, 2016 11:18 am

I have a very simple app to test tsNet.. (code extracted from Charles demo stack)

I can push app straight to my Android device using the test button, and save as standalone - in v 8.0 / v8.0.2 / 8.1 / 8.1.1 rc2...I know tsNet wont work in these builds but is still builds and deploys. I cannot however build app in any build after this, upto 9.0 dp2.. I get "Could not encode class bundle"

Thinking this was my app, i donwloaded Charles demo stack - tried to push that to my Android device and got the same error !?

Does anybody have an idea as to what is causing the encode error?

Cheers
Paul

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 730
Joined: Fri Feb 06, 2015 4:03 pm

Re: could not encode class bundle

Post by LiveCode_Panos » Wed Dec 14, 2016 11:28 am

Hi Paul,

Just a rough guess, have you by any chance changed the "Identifier" in the Android Standalone Settings, and include something that has spaces or other non-allowed chars?

Best,
Panos
--

paulrichards999
Posts: 18
Joined: Thu Sep 04, 2014 3:32 pm

Re: could not encode class bundle

Post by paulrichards999 » Wed Dec 14, 2016 11:42 am

Hi Panos,

No - the identifier is simply com.paulrichards.testing. version: 1.0.0 version code: 1 Signing: Sign for development only.

To test further, I created a new Stack, added 1 button and configured deployment to Android only.. Used the test button, and it deployed to device.

Added this code to the button: (which is the code behind HTTP Get Example button on Charles demo stack)

on mouseUp
local tRequestHeaders, tResponseHeaders, tResult, tBytes, tData
local tSettings, tCharNo, tUrl, tProxyUrl

put field "http_url" into tUrl
put empty into field "response"

-- Set proxy for HTTP(S) connections, if required
put field "proxy" into tProxyUrl
if tProxyUrl is not empty then
put offset("://", tProxyUrl) into tCharNo
put offset(":", tProxyUrl, tCharNo + 3) into tCharNo
if tCharNo is 0 then
put ":80" after tProxyUrl
end if
tsNetSetProxy tProxyUrl
else
tsNetSetProxy ""
end if

-- Build headers for HTTP request
put "User-Agent: LiveCode (" & the platform & ")" & cr into tRequestHeaders

-- Disable connection re-use if required
if the hilite of button "Reuse Connection" is false then
put true into tSettings["no_reuse"]
end if

-- Flag that we want to be able to store the sent headers for
put true into tSettings["save_sent_headers"]

put tsNetGetSync(tUrl, tRequestHeaders, tResponseHeaders, tResult, tBytes, tSettings) into tData

if the first word of tResult is not "tsneterr:" then
-- For HTTP(s) requests, check response code to confirm success or failure
if char 1 of tResult is not "2" then
answer "HTTP response code" && tResult && "returned from server"
end if
else
answer "Error" && tResult && "returned from server"
end if

-- At this point:
-- tResponseHeaders contains the headers returned from the server
-- tRequestHeaders contains the headers that were sent to the server
put tData into field "response"
end mouseUp

Save - TEST - unable to build app for testing: could not encode class bundle ?!?

Remove code from button - It deploys again. (most odd)

Add code to button

on mouseUp
get URL "https://www.google.co.uk"
end mouseUp

Save - TEST - could not encode class bundle!?! It appears anything internet related is causing this error on mouseup - answer "hello" end mouseUp works perfectly fine.

I am using Indy edition.

paulrichards999
Posts: 18
Joined: Thu Sep 04, 2014 3:32 pm

Re: could not encode class bundle

Post by paulrichards999 » Wed Dec 14, 2016 11:45 am

and the test listed above was done in 9.0 dp2 - although I have been getting this same mesasge on various versions of 8.1.x. I am also using Windows 10

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 730
Joined: Fri Feb 06, 2015 4:03 pm

Re: could not encode class bundle

Post by LiveCode_Panos » Wed Dec 14, 2016 2:26 pm

Hi Paul,

This is strange. I have just tested on LC 9 DP-2, using your sample button script, and I can successfully build an Android standalone and deploy it to my Android phone. I have tested on both Windows 10 and OS X 10.11.

I have also tested with both "Search for Inclusions" and "Select Inclusions" (and added tsNet).

I suggest you file a bug report (http://quality.livecode.com) and make sure you attach a sample stack.

Best regards,
Panos
--

paulrichards999
Posts: 18
Joined: Thu Sep 04, 2014 3:32 pm

Re: could not encode class bundle

Post by paulrichards999 » Wed Dec 14, 2016 3:12 pm

Hi Panos..

I put "answer the result " before Throw "could not encode class bundle" in revSaveAsAndroidStandalone script

and I got this error:

trouble processing:
bad class file magic (cafebabe) or version(0033.0000)
...while parsing tsNet/LC$1.class
... while processing tsNet/LC$1.class

trouble processing:
bad class file magic (cafebabe) or version(0033.0000)
...while parsing tsNet/LC$1.ActivityResultCallback.class
... while processing tsNet/LC$1.ActivityResultCallback.class

trouble processing:
bad class file magic (cafebabe) or version(0033.0000)
...while parsing tsNet/LC$1Error.class
... while processing tsNet/LC$1Error.class

trouble processing:
bad class file magic (cafebabe) or version(0033.0000)
...while parsing tsNet/tsNet.class
... while processing tsNet/tsNet.class

Amongst others - 7 errors in total
Bug logged: 19001

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 730
Joined: Fri Feb 06, 2015 4:03 pm

Re: could not encode class bundle

Post by LiveCode_Panos » Wed Dec 14, 2016 4:31 pm

Thanks for the info, Paul.

I have replied in the bug report: http://quality.livecode.com/show_bug.cgi?id=19001

Best,
Panos
--

paulrichards999
Posts: 18
Joined: Thu Sep 04, 2014 3:32 pm

Re: could not encode class bundle

Post by paulrichards999 » Thu Dec 15, 2016 11:06 am

After the wonderul guidance from Panos..

I checked what Android Build-tools were installed (SDK Manager) and found I was running 17 so installed 19.03 and hey presto - App now saves and deploys.

Thanks Panos.

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 730
Joined: Fri Feb 06, 2015 4:03 pm

Re: could not encode class bundle

Post by LiveCode_Panos » Thu Dec 15, 2016 11:54 am

Thank you for the update, Paul.

I am glad the issue is resolved :)

Post Reply

Return to “Android Deployment”