It is currently Tue May 23, 2017 1:47 am



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 11:04 am 
Offline

Joined: Mon Sep 12, 2016 12:53 pm
Posts: 9
Hello i have used basic compiler on remix os and work fine. Now i recompile the app on Koplayer emulator and i have this error:
DIVIDE BY ZERO AT:
ratio=min(11/w,11/h)

What appens ?
Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 12:16 pm 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Hello Mike,

I just checked the Compiler source code and this line is not part of it.

I would need more detail: first useful info would be when this error occurs exactly ?

Thanks,
Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 12:22 pm 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Also please answer my other question linked to your GW problem here: program-work-fine-on-editor-mode-fails-when-build-apk-t4694.html

If you found the source of your problem and were able to fix it, it is important to report so that other users with the same problem can solve it too (typically user chrisRoald here).

Thanks,
Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 12:41 pm 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2185
Location: romania
mike67 wrote:
Hello i have used basic compiler on remix os and work fine. Now i recompile the app on Koplayer emulator and i have this error:
DIVIDE BY ZERO AT:
ratio=min(11/w,11/h)

What appens ?
Thanks in advance.

if u don't initialize your variables, default values for 'w' and 'h' are 0 (zero) so '11/w' > divide by zero


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 12:48 pm 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
gikam wrote:
if u don't initialize your variables, default values for 'w' and 'h' are 0 (zero) so '11/w' > divide by zero

Thanks Gika.
Doesn't help us though :) as I said there is no such code in the Compiler...

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 1:22 pm 
Offline
User avatar

Joined: Sun Nov 23, 2014 8:15 am
Posts: 2185
Location: romania
mougino wrote:
gikam wrote:
if u don't initialize your variables, default values for 'w' and 'h' are 0 (zero) so '11/w' > divide by zero

Thanks Gika.
Doesn't help us though :) as I said there is no such code in the Compiler...

that was what mike exposes as the error source


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Sun Nov 27, 2016 1:27 pm 
Offline

Joined: Mon Sep 12, 2016 12:53 pm
Posts: 9
The code arent in my app also. I have attached a video of compilation. Please see it with vlc.
Thanks in advance.


Attachments:
File comment: video
Video.7z [824.61 KiB]
Downloaded 9 times
Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Mon Nov 28, 2016 1:26 am 
Offline
User avatar

Joined: Tue Jan 03, 2012 9:31 am
Posts: 5518
Location: Paris, France
Thanks Mike!

This is a very interesting problem ;)

I managed to find the incriminated line in the Compiler code, it is not ratio=min(11/w,11/h) but in fact ratio=min(ll/w,ll/h) :P can you spot the difference??

This line is in the function GrSaveIcons() whose goal is to resize the app icon and save it to the different res/drawable-* folders of the project.
This code is a very small place (~10 lines) where I open graphic (GR) mode, do the resize operations, then close GR and continue on with HTML mode...
The Compiler runs 99,5% of the time in HTML mode, this is the only place I use the GR mode.

As Gika pointed out, the error thrown shows either w or h are null (equal to zero). I get w and h from the following command: Gr.Bitmap.Size original, w, h where 'original' is the pointer to the picture you chose for icon, loaded thanks to Gr.Bitmap.Load original, src_img$.
Most probable cause is that Gr.Bitmap.Size returns 0x0 as the picture size.

And that's where it becomes very interesting.
A look at your video gives us the answer. Most interesting info is in the sum-up screen, just before hitting "COMPILE !":
BASIC! Compiler wrote:
App icon: TimeTable.ico

It may seem obvious for a newcomer to use a ".ico" as a source for an Android app "icon" but in the Android world it is not ;)
What Android calls "icon" are in fact PNGs. The Compiler goes around that by transforming any input image to the PNG format, as well as doing the resizing.
I was aware of users using Jpegs or Bmps or even Gifs as input for icon, I tested all these cases, but it is the first time I see someone taking a .ico as source for icon ;)

Ok so why is there an error in the Compiler?
I first thought that when the image was in an unrecognized format and could not be loaded (pointer returned by Gr.Bitmap.Load of -1) then Gr.Bitmap.Size would return 0x0, but I was wrong. A little search in Run.java showed me in this case (pointer of -1) a runtime error is thrown.

So what's amazing is that the image could be loaded by Gr.Bitmap.Load but then its size is genuinely returned as 0x0.
So here we may have found a BASIC! limitation (I would not say bug): a .ico is known to contain several images of several dimensions.
Maybe the code for Gr.Bitmap.Size does not handle that and returns 0x0.
Further search shows *.ico are not supposed to be supported by Android.

What's funny though is that the Compiler doesn't complain until resizing time. You can see your .ico in the list of images, you can select it, the Compiler even shows the correct image size in the "App name+icon" screen! That is because we are working in HTML mode ;)
In HTML mode, the routines used are not Android ones (GR mode uses Android routines) and a .ico is well recognized...

Now, knowing all that, what should be our course of action?
Should the Compiler forbids to use .ico as source of images? Should I remove them from the list of selectable images?

Nicolas

_________________
- Creator of the Android BASIC! Compiler


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Mon Nov 28, 2016 9:22 am 
Offline

Joined: Mon Sep 12, 2016 12:53 pm
Posts: 9
According to your indication i change TimeTable.ico to TimeTable.png. Now compiler go to successive step but return this error:
error creating R.java sh: [1]: /data/data/com.rfo.compiler/aapt: not executable: magic 7F45

PS. Pheraps is best to remove .ico selection from compiler.


Top
 Profile  
 
 Post subject: Re: Basic compiler on Koplayer emulator faile compiler
Unread postPosted: Mon Nov 28, 2016 11:09 am 
Offline
User avatar

Joined: Thu Nov 24, 2016 8:26 pm
Posts: 49
Location: GA, USA
mike67 wrote:
According to your indication i change TimeTable.ico to TimeTable.png. Now compiler go to successive step but return this error:
error creating R.java sh: [1]: /data/data/com.rfo.compiler/aapt: not executable: magic 7F45

PS. Pheraps is best to remove .ico selection from compiler.

It's not as simple as just changing the file extension mike67, changing the extension does not take care of the physical conversion from .ico to .png. That has to be done in photo software. Every picture format has its own header information and they all differ.

I too think that the ico format should be removed from the list, since it is officially not supported by Android.

_________________
A good programmer is someone who always looks both ways before crossing a one-way street.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
suspicion-preferred