Mintoris Forum

Author Topic: App Creation Tutorial using Basic Runtime (beta)  (Read 13045 times)

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
App Creation Tutorial using Basic Runtime (beta)
« on: Mar 12, 2013, 12:23 AM »
I just published the BasicRuntime.apk app and a compiled version of the classic P9 demo that uses the runtime.

Below is the link to the template Android Eclipse project that can be used to compile your Basic apps. I'm currently taking notes and planning out the instructional videos. If anyone knows Eclipse and wants to try compiling your Basic programs, please use the project below. We will consider this whole process in beta testing and your feedback would be welcome before I put the videos together.

Here is a link to the Basic Runtime app.

BasicRuntime.apk - Version 5.12.5

If you want to get started installing the Android development environment watch the following video.

How to Install Android SDK + ADT into Eclipse IDE on Windows OS. (tutorial)

Once you have the development environment installed, watch the next video which shows how to put the Basic project together.

Mintoris Basic App Creation - Part 1

Part 2 explains how to export the apk file from Eclispe and sign it. The creation of a digital signature is also covered.

Mintoris Basic App Creation - Part 2

Below is a link to RuntimeDemo.zip - Version 1.2, an Android Eclipse project you need to create an apk. You should use your PC to download this file, it does not belong on your Android device.
« Last Edit: May 03, 2013, 09:13 PM by Chuck »

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #1 on: Mar 15, 2013, 12:24 AM »
I've now posted the second app creation tutorial video. A link to it can be found in the original post above.

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #2 on: Mar 16, 2013, 11:21 AM »
I have done the generic tutorial and your first tutorial.  It needs to be emphasized (as I discovered) that if you have JDK 7 only it will not work. You still need to download and install JDK 6, and in the project properties/Java Compiler window, set compiler compliance  level to 1.6.

So anyway I followed the instructions in your first video and was able to build and "run" the blackhole program. I changed the program to reference the file names without a path, thinking that if I put the files
in res.raw they would be found. But is still looked for them in sdcard/Mintoris.Basic (so i put them there and it ran). You will no doubt in you next tutorial tell me what to do with files.

When testing I just "ran" the project; it automatically loaded the apk into Blue Stacks (which was running) and ran the program.  Blue Stacks is much faster than the emulator and not as cranky.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #3 on: Mar 16, 2013, 09:17 PM »
I haven't had time to do the third video yet but basically you:

- Zip your data dir. Your dir must be in the root of the data directory Mintoris.Basic/Data. Name the zip file data.zip

- Use something similar to this to zip your data dir. MediaFiles is an example name, choose your own.
dim files$(0) = "MediaFiles"
print "Zipping…"
wait 1
Zip "data.zip", files$()
print "Done"


- Put the data.zip file in your res/raw directory.

- In AutoRun.java change the following lines

   // Set the following constant to null if you do not use external storage.
   private static final String BASE_DIR_NAME = "MyRootDir";

   // Set the zip file name to null if you don't have data to pre-load.
   private static final String DATA_ZIP_NAME = "data.zip";

- Uncomment the following lines in preloadData(Bundle bundle)

// Uncomment the next three lines if you need to install data files.         
//         String sDataZip = sDataDir + "/" + DATA_ZIP_NAME;
//         if(‼copyToSDCard(R.raw.data, sDataZip))
//            return false;


That should create a new dir in the root of the sdcard called MyRootDir (Pick your own dir name). MyRootDir will then act as the root Data dir instead of Mintoris.Basic/Data. Under that dir your data.zip will automatically be unziped before the first run of your program.

You will also want to go through the manifest and delete any permissions for features you don't use.

Let me know how that goes.

-Chuck
« Last Edit: Mar 17, 2013, 02:38 AM by Chuck »

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #4 on: Mar 17, 2013, 12:56 PM »
Yesterday I went thru your video and signed and aligned an apk.
Today I followed the instructions above and rebuilt the apk that I then signed and aligned.
I installed the apk on two different tablets. On one of the two tablets it created the directory named in BASE_DIR_NAME. Stored in this directory was the data.zip file, but nothing was unzipped. On the other tablet no directory was created.

On both tablets, running the app caused a visit to the play store to install the Basic Runtime App. After I installed that, the original app could not find it and wanted to install it again. How can I help to resolve this?

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #5 on: Mar 17, 2013, 06:49 PM »
The installation of the runtime app is the trickiest part. I will have to do more testing. The part that disturbs me is the time no data directory was created. Did you remove any permissions from the manifest? I think the only permission you will need is:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

It might be better if I just exited the app after the user is re-directed to the market for install. Once install is complete then they can restart the app.
« Last Edit: Mar 17, 2013, 06:57 PM by Chuck »

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #6 on: Mar 17, 2013, 07:07 PM »
That permission is duplicated in the Manifest -- I could try with just one I suppose.
I think it would be adequate to just exit the app after the redirect.



Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #7 on: Mar 17, 2013, 07:23 PM »
As long as you didn't delete that permission you will be ok. I just need some time to work on this.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #8 on: Mar 17, 2013, 09:56 PM »
jclemens, I've updated the RuntimeDemo-1.1.zip above. I believe that the problems are fixed. You can start over or just replace AutoRun.java and res/values/strings.xml.

Thanks for your help,
-Chuck

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #9 on: Mar 18, 2013, 03:20 PM »
I replaced those two files, editing as indicated. I also made a new zip file without a directory name with the files, which is the right thing to do if DATA_DIRECTORY_NAME = "". The way autorun.java is programmed, any error from run_program() causes a redirect to load the runtime app.  The error that is actually occuring (which flashed too fast before) is showing as "storage error make sure your sd card is plugged in".  So the app can never run.  This is happening on one tablet and on blue stacks. On the other tablet the app runs fine.  Both tablets are running android 4.0.3.

I just noticed. If you go into Settings on either tablet and look at my blackhole app it shows NO permissions.



« Last Edit: Mar 18, 2013, 07:06 PM by jclemens »

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #10 on: Mar 18, 2013, 10:27 PM »
jclemens, I really appreciate your help and I am very glad it is you I'm working with on this. I can see where a less experienced user would have been lost.

Ok, I did a lot of work on the RuntimeDemo and posted a new version above. I think I found why the data was not being extracted to the sdcard. I believe, if you look on the devices where the data did not extract, you will find that the data.zip file is in the data dir but did not unzip. This should be fixed.

Again you will need to copy AutoRun.java and res/values/strings.xml to your project. Make sure the package name at the top of AutoRun.java matches the package name in the manifest. Once you get everything setup ready to compile, click on the project, then go to the project menu at the top of the screen and select clean. Then clean your project.

Once you reinstall the apk on your devices, make sure all the permissions you declared in the manifest show up during install and when you look at the app in settings. Setting the permissions correctly is REQUIRED by Googles terms of service. BasicRuntime.apk declares all the correct permissions, and it is the app that really uses them. Since the app you create does not actually do the work, it would not look right to the user if you did not declare all the permissions you use in the runtime. Google might consider this a security loophole which might lead to the downfall of the Basic runtime.

I also added a feature where the data will be re-extracted if the version number changes. The version number is set at the top of the AndroidManifest.xml file. This would be necessary if your data files changed after an update.

To enable this feature, add a file name to the following line.

   private static final String VERSION_CODE_FILE = "current_version.dat";

Then any time the you change the version number in the manifest your data will be re-extracted.

In your case, since you just have data and sound files which prob won't change, you can leave it null and the feature will not be used.

   private static final String VERSION_CODE_FILE = null;

If you need to update your data files later you can set a current version file name then and the data will update.

-Chuck
« Last Edit: Mar 18, 2013, 10:30 PM by Chuck »

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #11 on: Mar 19, 2013, 09:42 AM »
I will use your new files and let you know if they work, but I had already fixed what I had so everything worked. After I noticed that the app had no permissions, I went back and looked at the AndroidManifest.xml.  There was a comment <‼-- preceding the permissions section of the file. I didn't put that there‼ I removed the "<‼--", rebuilt and everything worked.  So this was the only thing that was ever wrong, really. That and one of my tablets allowing writes to the SDCARD without permission.  That is the same weird little tablet that won't let me install Basic from the play store.

Originally when it created the directory I specified in BASE_DIR_NAME and had set DATA_DIR_NAME to null, it  just stored the data.zip in the new directory. That is because I had followed your directions literally and put the files to be zipped in a subdirectory called mediafiles and zipped them as specified. After I zipped them into a data.zip with no directory name stored, they unzipped during installation just fine.

I will try out your new AutoRun.java and res/values/strings.xml today and let you know the result.



« Last Edit: Mar 19, 2013, 12:27 PM by jclemens »

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #12 on: Mar 19, 2013, 01:06 PM »
The new AutoRun.java and res/values/strings.xml work just fine after the appropriate edits.
I guess I'm through with this unless you want me to test further changes. Your new VERSION_CODE_FILE feature sounds like a good addition, although I have done nothing to test it.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #13 on: Mar 19, 2013, 05:57 PM »
jclemens, I've very glad you got everything working. I was beginning to get worried. I will have to go back and fix Part 2 of the tutorial before I go on to Part 3.

Thanks again,
-Chuck

jclemens

  • Sr. Member
  • ****
  • Posts: 146
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #14 on: Mar 20, 2013, 02:26 PM »
I went back and looked at the runtimedemo.zip files. I had all three; the first one had the androidmanifest.xml with permissions commented out. The ones I downloaded on 3/18 and 3/19 were ok, but by then I was just copying autorun.java and strings.html.  The first one I obviously just edited the package name and didn't review the rest. Remember the issue about having to have Java 6 even if you have Java 7. And if you have Java 7, going to project/properties/java compiler and setting compiler compliance level to 1.6.

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #15 on: Mar 20, 2013, 04:55 PM »
Ah, that explains the permissions problem. Yes, I'm going to insert a comment about Java 6 and the compiler compliance level into the the first video. Just been a little busy. I think that the only permission you need for your app is the external storage one.

-Chuck

jdi menya

  • Full Member
  • ***
  • Posts: 27
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #16 on: Mar 27, 2013, 07:50 PM »
hello to all‼  i try to do my own app, install all staff, did the tutorial part 1 and it runs on emulator, but when my program has to show two .png files, it get an error:

runtime error
image file does not exist.
/mnt/sdcard/mintoris.basic/graphics/IMG3.png

can anyone help me please to solve this problem? thank you
p.s.  sorry for not very good english :)


jdi menya

  • Full Member
  • ***
  • Posts: 27
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #17 on: Mar 27, 2013, 08:25 PM »
sorry for interrapting. after second try i get whole my program running on emulator:P now i will try to do tutorial part2. i really like the mintoris basic:P

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #18 on: Mar 27, 2013, 08:58 PM »
sorry for interrapting. after second try i get whole my program running on emulator:P now i will try to do tutorial part2. i really like the mintoris basic:P

That's awesome‼ Let me know if you need help.

-Chuck

jdi menya

  • Full Member
  • ***
  • Posts: 27
Re: App Creation Tutorial using Basic Runtime (beta)
« Reply #19 on: Mar 27, 2013, 09:11 PM »
i did part 2 and i need help, please.   i send  app and install it to my phone and get nearly the same error message as before: 
runtime error
image file does not exist.
/storage/sdcard0/MyRootDir/graphics/IMG3/png