Unfortunately

Monkey Targets Forums/Android/Unfortunately

APC(Posted 2015) [#1]
I am trying to test my app on the Android emulator and I get this error Unfortunately App has Stopped. Some times it runs once then If I try to run it again it gives me this error.

By the way this app works fine on HTML5 and iOS!
I searched all over the internet but nothing I try works like:
- Clearing the App CACHE
- Increasing the VM HEAP and Memory on the Emulator AVD Manager

Did any of you got this issues?

Here is the full log including the error:
C:\Program Files (x86)\MonkeyXPro84e\Bin\transcc_winnt.exe -run -config=release -target=Android_Game_(Api_10) -modpath="C:\Program Files (x86)\MonkeyXPro84e\modules;C:\Program Files (x86)\MonkeyXPro84e\modules_ext;C:\Program Files (x86)\MonkeyXPro84e\modules\diddy" "C:/Users/Arolodo Carvalho/Documents/Monkey/Defender1/Defender1.monkey"
TRANS monkey compiler V1.85
Parsing...
Semanting...
Translating...
Building...
Buildfile: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\build.xml

-check-env:
[checkenv] Android SDK Tools Revision 24.3.4
[checkenv] Installed at C:\Users\Arolodo Carvalho\Documents\android-sdk

-setup:
[echo] Project Name: MonkeyGame
[gettype] Project Type: Application

-pre-clean:

clean:
[delete] Deleting directory C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin
[delete] Deleting directory C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\gen
[getlibpath] Library dependencies:
[getlibpath] No Libraries
[subant] No sub-builds to iterate on

BUILD SUCCESSFUL
Total time: 0 seconds
Buildfile: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\build.xml

-set-mode-check:

-set-release-mode:

-release-obfuscation-check:
[echo] proguard.config is ${proguard.config}

-pre-build:

-check-env:
[checkenv] Android SDK Tools Revision 24.3.4
[checkenv] Installed at C:\Users\Arolodo Carvalho\Documents\android-sdk

-setup:
[echo] Project Name: MonkeyGame
[gettype] Project Type: Application

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.1
[echo] Resolving Build Target for MonkeyGame...
[gettarget] Project Target: Android 4.4.2
[gettarget] API level: 19
[echo] ----------
[echo] Creating output directories if needed...
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\rsObj
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\rsLibs
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\gen
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\classes
[mkdir] Created dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\dexedLibs
[echo] ----------
[echo] Resolving Dependencies for MonkeyGame...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with 'release'...
[subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files...
[aidl] No AIDL files to compile.
[echo] ----------
[echo] Handling RenderScript files...
[echo] ----------
[echo] Handling Resources...
[aapt] Generating resource IDs...
[echo] ----------
[echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
[javac] Compiling 3 source files to C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\classes
[javac] warning: [options] source value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] target value 1.5 is obsolete and will be removed in a future release
[javac] warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
[javac] Note: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\src\com\apdconsultinginc\defender1\MonkeyGame.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\src\com\apdconsultinginc\defender1\MonkeyGame.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 3 warnings

-post-compile:

-obfuscate:

-dex:
[dex] input: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\classes
[dex] Converting compiled files and external libraries into C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\classes.dex...

-crunch:
[crunch] Crunching PNG Files in source dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\res
[crunch] To destination dir: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res
[crunch] Processing image to cache: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\res\drawable-hdpi\icon.png => C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-hdpi\icon.png
[crunch] (processed image to cache entry C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-hdpi\icon.png: 69% size of source)
[crunch] Processing image to cache: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\res\drawable-ldpi\icon.png => C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-ldpi\icon.png
[crunch] (processed image to cache entry C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-ldpi\icon.png: 0% size of source)
[crunch] Processing image to cache: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\res\drawable-mdpi\icon.png => C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-mdpi\icon.png
[crunch] (processed image to cache entry C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\res\drawable-mdpi\icon.png: 0% size of source)
[crunch] Crunched 3 PNG files to update cache

-package-resources:
[aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating MonkeyGame-release-unsigned.apk for release...

-post-package:

-release-prompt-for-password:

-release-nosign:

-release-sign:
[echo] Signing final apk...
[zipalign] Running zip align on final apk...
[echo] Release Package: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\MonkeyGame-release.apk
[propertyfile] Creating new property file: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\build.prop
[propertyfile] Updating property file: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\build.prop
[propertyfile] Updating property file: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\build.prop
[propertyfile] Updating property file: C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\build.prop

-post-build:

release:

install:
[echo] Installing C:\Users\Arolodo Carvalho\Documents\Monkey\Defender1\Defender1.buildv84e\android_new\bin\MonkeyGame-release.apk onto default emulator or device...
[exec] pkg: /data/local/tmp/MonkeyGame-release.apk
[exec] Success
[exec] 1325 KB/s (1698022 bytes in 1.250s)

BUILD SUCCESSFUL
Total time: 9 seconds
Starting: Intent { cmp=com.apdconsultinginc.defender1/.MonkeyGame }

--------- beginning of system

--------- beginning of main

09-21 09:13:14.310 2333 2333 E memtrack: Couldn't load memtrack module (No such file or directory)

09-21 09:13:14.310 2333 2333 E android.os.Debug: failed to load memtrack module: -2

09-21 09:13:14.400 1005 1005 E EGL_emulation: tid 1005: eglCreateSyncKHR(1243): error 0x3004 (EGL_BAD_ATTRIBUTE)

09-21 09:13:14.500 1675 1824 E Surface : getSlotFromBufferLocked: unknown buffer: 0x7f3122db4de0

--------- beginning of crash

09-21 09:13:14.750 2343 2357 E AndroidRuntime: FATAL EXCEPTION: GLThread 131

09-21 09:13:14.750 2343 2357 E AndroidRuntime: Process: com.apdconsultinginc.defender1, PID: 2343

09-21 09:13:14.750 2343 2357 E AndroidRuntime: java.lang.IllegalArgumentException: No config chosen

09-21 09:13:14.750 2343 2357 E AndroidRuntime: at android.opengl.GLSurfaceView$BaseConfigChooser.chooseConfig(GLSurfaceView.java:870)

09-21 09:13:14.750 2343 2357 E AndroidRuntime: at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1024)

09-21 09:13:14.750 2343 2357 E AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1401)

09-21 09:13:14.750 2343 2357 E AndroidRuntime: at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

09-21 09:13:15.780 1005 1005 E SurfaceFlinger: rejecting buffer: bufWidth=905, bufHeight=400, front.active.{w=129, h=129}

09-21 09:13:15.800 1348 2109 E Surface : getSlotFromBufferLocked: unknown buffer: 0x7f3121d226d0

09-21 09:13:18.350 1348 2109 E Surface : getSlotFromBufferLocked: unknown buffer: 0x7f3121d21b00


Xaron(Posted 2015) [#2]
That's a bit vague. Does it run without problems on HTML5, Desktop? Could you share your error log?


APC(Posted 2015) [#3]
Xaron,

I added the entire log.on my original post. I see errors coming from the emulator back to my Jungle IDE.


MikeHart(Posted 2015) [#4]
Aroldo, using fantomEngine here?


APC(Posted 2015) [#5]
Hi Mark, no I am not.

I don't have an Android device yet. Do you have one? Can you test my app?


Xaron(Posted 2015) [#6]
Are you still using Mojo1? If so, in your config.monkey under the Android new target, set this:

#OPENGL_GLES20_ENABLED=False



APC(Posted 2015) [#7]
Xaron,

No I am using Mojo2 , and the latest Monkey Version, MonkeyPro84e I check the CONFIG.MONKEY :

#OPENGL_CLES_ENABLED=False
#ANDROID_NATIVE_GL_ENABLED=False


Xaron(Posted 2015) [#8]
Right... I haven't used Mojo2 yet so maybe this is really a bug in it.


APC(Posted 2015) [#9]
Okay,

The first time I am building my apps for ANDROID target , Like I mentioned before this app is working fine on HTML5 (See this game on the Monkey App Defender 1 And it is available at the App Store Apple App Store

Did a small application and deployed on the Android Emulator and I works, the diference is that Defender 1 runs the first time, but if I click on the Home button and try to reopen it or close it and try to run it again on the emulator the "Unfortunately, "App" has stopped" error happens.
If I clear the cache or delete the App from the Android Emulator and install it again it will work under the same conditions I mentioned above. During the time it works I can play the game, save the high score, change settings and the app behaves as it should.

So at this point I still can pin point the issue.

Any ideas?


APC(Posted 2015) [#10]
Can some one compile and run this on ANDROID Target? I posted this before but I cant find it.
This is a Particle System
I replicates the problem I am having.

Strict
#rem
Script:	Particle Blast
Description: Particle Blast has two particles systems. Particle Emitter and Fireworks
			 Particle Emitter
			 Includes the classes Particle Emmiter, Single Particle and PVector, it generates endless particles.
			 Fireworks
			 Simulates fireworks explosion or implosion, it genereates a fixed number of particles.
			 Includes the classes ParticleSystem, Particle .
			 
			 The Game Class is the main program that demonstrate the use of the particles systems and allows
			 the user to control the behavior of the particles systems.
			 
			 Click  or touch the screen to launch the fireworks, the emitter launches bubles or sparkles at the top of a tourch!
			 
			 This program works on Desktop computers or Mobile Devices.
			 
			 Particle Systems Controls (clicking on the menu options will cycle through the values)
			 
			 Number Particles..... Change the number of particles in the Fireworks (does not afect the Emitter)
			 Size................. Change the particle size on both systems
			 Life................. Changes the life of the fireworks particles only. (The emiter has a fixed life value)
			 Mode................. Explode or Implode for the fireworks particles only
			 Type................. Draws a Square or Circle and aftects both systems
			 Sound................ Turns the sound on or off and afects both systems and the menu selection.
			 Colors............... Changes the colors of the the fireworks particles only. It has fixed colors, random and confetti.
			 Emitter.............. Turns the particles emmiter on or off.
			 
Author: Aroldo Carvalho
Company: APD Games
Date:Aug 28, 2014
Version: 1.0
#end

Import fantomEngine
Import pvector

Global g:game

Class Particle

	Field x:float
	Field y:float
	Field sine:Float
	Field cosine:Float
	Field speed:Float
	Field life:Float
	Field colors:Float[] 'points To array of colors

	Method isDead:Bool()
		If (life < 0.0)
			Return True
		Else
			Return False
		EndIf
	End
End
Class ParticleSystem
	Field origin:PVector
	Field particlesList:= New List<Particle>
	Field m_numparticles:Int
	Field life:Int
	Field dot_w:int, dot_h:Int
	Field et:Float, m_time:Float
	Field particolor:Float[][]
	Field colorIdx:Int = 0
	
	Method New()
		dot_w = 1
		dot_h = dot_w
	End
	Method SetDotSize:Void(pSize:int)
		dot_w = pSize
		dot_h = dot_w
	End
	Method SetNumParticles:Void(nParticles:int)
		m_numparticles = nParticles
	End
	Method SetLife:Void(pLife:int)
		life = pLife
	End
	Method Update:Void()
		Local newtime:float = Millisecs()
		Local beforeTime:float = newtime
		et = (newtime - m_time) / 1000
		If (et > (1.0 / 15.0))
			et = 1.0 / 15.0
		EndIf

		For Local particle:= EachIn particlesList
			Local p:Particle = particle
			particle.life = particle.life - et
			If (particle.life <= 0.0)
				particlesList.Remove(particle)
			Else
				particle.x = particle.x + (particle.sine * particle.speed * et)
				particle.y = particle.y + (particle.cosine * particle.speed * et)
			EndIf
		Next
	End
	Method addParticles:Void(num:Int, mode:Int, life:Float, cx:Int, cy:Int, colors:float[], mix:Bool)
		Local i:int
		Local angle:Float
		Local dist:Float
		Local particle:Particle

		For Local i:Int = 0 Until num - 1
			particle = New Particle()
			If (mix)
			 CreateMixedColors()
				particle.colors = particolor[Rnd(particolor.Length - 1)]
			Else
				particle.colors = colors
			EndIf
			
			angle = Rnd(90) * (app.PI * 2)
			particle.sine = Sin(angle)
			particle.cosine = Cos(angle)
			dist = Rnd(16)

			If (mode)	'1=Explosion or 0=Implosion
				' * Exploding *
				particle.speed = 1.5 + Rnd(45)
				particle.life = life
				particle.x = cx + particle.sine * dist
				particle.y = cy + particle.cosine * dist

			Else
				' * Imploding *
				particle.speed = 1.5 + Rnd(90)
				particle.life = life
				particle.x = cx - (particle.sine * (dist + particle.speed * particle.life))
				particle.y = cy - (particle.cosine * (dist + particle.speed * particle.life))
			EndIf
			
			particlesList.AddLast(particle)
		Next
		colorIdx += 1		' next confetti set of colors
		If colorIdx > particolor.Length() -1 Then colorIdx = 0
	End
	Method CreateMixedColors:Void()
		particolor = particolor.Resize(6)
		For Local i:Int = 0 Until particolor.Length()
			particolor[i] = New Float[3]
		Next
		Select colorIdx
			Case 0
				particolor[0] =[255.0, 255.0, 255.0] 	' White
				particolor[1] =[255.0, 255.0, 255.0] 	' White
				particolor[2] =[255.0, 0.0, 0.0]		' Red
				particolor[3] =[255.0, 0.0, 0.0]		' Red
				particolor[4] =[255.0, 128.0, 0.0]		' Orange
				particolor[5] =[255.0, 128.0, 0.0]		' Orange
			Case 1
				particolor[0] =[0.0, 255.0, 255.0]		' Aqua
				particolor[1] =[0.0, 255.0, 255.0]		' Aqua
				particolor[2] =[0.0, 0.0, 255.0]		' Blue
				particolor[3] =[0.0, 0.0, 255.0]		' Blue
				particolor[4] =[0.0, 0.0, 255.0]		' Blue
				particolor[5] =[0.0, 255.0, 255.0]		' Aqua
			Case 2
				particolor[0] =[255.0, 0.0, 0.0] 		' Red
				particolor[1] =[255.0, 0.0, 0.0] 		' Red
				particolor[2] =[0.0, 0.0, 255.0]		' Blue
				particolor[3] =[0.0, 0.0, 255.0]		' Blue
				particolor[4] =[0.0, 0.0, 0.0]			' White
				particolor[5] =[0.0, 0.0, 0.0]			' White
			Case 3
				particolor[0] =[0.0, 255.0, 0.0] 		' Green
				particolor[1] =[255.0, 0.0, 0.0] 		' Red
				particolor[2] =[0.0, 0.0, 255.0]		' Blue
				particolor[3] =[0.0, 0.0, 0.0]			' White
				particolor[4] =[255.0, 0.0, 128.0]		' Pink
				particolor[5] =[255.0, 255.0, 0.0]		' Yellow
			Case 4
				particolor[0] =[255.0, 0.0, 0.0] 		' Red
				particolor[1] =[255.0, 0.0, 0.0] 		' Red
				particolor[2] =[255.0, 255.0, 0.0]		' Yellow
				particolor[3] =[255.0, 255.0, 0.0]		' Yellow
				particolor[4] =[255.0, 0.0, 0.0]		' Red
				particolor[5] =[255.0, 255.0, 0.0]		' Yellow
			Case 5
				particolor[0] =[0.0, 0.0, 255.0]		' Blue
				particolor[1] =[0.0, 0.0, 255.0]		' Blue
				particolor[2] =[0.0, 255.0, 255.0]		' Aqua
				particolor[3] =[0.0, 255.0, 255.0]		' Aqua
				particolor[4] =[255.0, 0.0, 128.0]		' Pink
				particolor[5] =[255.0, 0.0, 128.0]		' Pink
		End
	End
	Method run:Void(pType:Bool)
		Update()
		display(pType)
	End
	Method display:Void(pType:Bool)
		Local memAlpha:Float = GetAlpha()
		Local memColor:Float[] = GetColor()

		For Local particle:= EachIn particlesList
			Local p:Particle = particle
			If (particle.y >= 50)
				Local c:float[] = particle.colors
				SetAlpha(0.8)
				SetColor(c[0], c[1], c[2])
				If pType
					DrawEllipse(particle.x, particle.y, dot_w, dot_h)
				Else
					DrawRect(particle.x, particle.y, dot_w, dot_h)
				EndIf
				
			EndIf
		Next

		SetAlpha(memAlpha)
		SetColor(memColor[0], memColor[1], memColor[2])
	End
	Method isDead:Bool()
		If (life < 0.0) ' Is the Particle alive or dead?
			Return True
		Else
			Return False
		EndIf
	End
End
Class SingleParticle
	Field location:PVector
	Field velocity:PVector
	Field acceleration:PVector
	
	Field lifespan:float
	Field d:Float = 5		' Diameter
	Field r:Float = d / 2	' Radius
	Field color:Float[3]
	Field pType:Bool = True

	Method New(l:PVector, c:Float[], size:Float, type:Bool)
		acceleration = New PVector(0, 0.05)
		velocity = New PVector(Rnd(-1, 1), Rnd(-2, 0))
		location = l.get()
		lifespan = 200.0
		color = c
		d = size
		pType = type
	End
	Method New(l:PVector)
		acceleration = New PVector(0, 0.05)
		velocity = New PVector(Rnd(-1, 1), Rnd(-2, 0))
		location = l.get()
		lifespan = 200.0
	End
	Method SetDotSize:Void(pSize:int)
		d = pSize
	End
	Method SetLife:Void(pLife:Float)
		lifespan = pLife
	End
	Method SetType:Void(type:Bool)
		pType = type
	End
	Method run:Void()
		Update()
		display()
	End
	Method Update:Void()
		velocity.add(acceleration)
		location.add(velocity)
		lifespan -= 2.0
	End
	Method display:Void()
		Local memAlpha:Float = GetAlpha()
		Local memColor:Float[] = GetColor()
		
		SetAlpha(0.9)
		SetColor(color[0], color[1], color[2])
		If pType
			DrawRect(location.x, location.y, d, d)
		Else
			DrawEllipse(location.x, location.y, d, d)
		EndIf
		
		SetAlpha(memAlpha)
		SetColor(memColor[0], memColor[1], memColor[2])
	End
	Method isDead:Bool()
		If (lifespan < 0.0)	' Is the Particle alive or dead?
			Return True
		Else
			Return False
		EndIf
	End
End
Class ParticleEmitter
	Field particlesList:= New List<SingleParticle>
	Field origin:PVector
	Field pSize:Int
	Field pType:Bool
	Field pLife:Float
		

	Method New(location:PVector)
		origin = location.get();
	End
	Method SetDotSize:Void(Size:int)
		pSize = Size
	End
	Method SetLife:Void(Life:Float)
		pLife = Life
	End
	Method SetType:Void(type:Bool)
		pType = type
	End
	Method addParticle:Void()
		Local color:Float[] =[Rnd(255), Rnd(255), Rnd(255)]
		particlesList.AddLast(New SingleParticle(origin, color, pSize, pType))
	End
	Method addParticle:Void(x:Float, y:Float)
		particlesList.AddLast(New SingleParticle(New PVector(x, y)))
	End
	Method run:Void()
		For Local particle:= EachIn particlesList
			Local p:SingleParticle = particle
			p.run()
			If (p.isDead())
				particlesList.Remove(particle)
			End
		Next
	End
End
Class game Extends App
	Field eng:engine
	
	Field font1:ftFont

	Field layerBackGround:ftLayer
	Field layerMenu:ftLayer
	
	Field ps:ParticleSystem
	Field pe:ParticleEmitter
	
	Field particolors:Float[][]

	Field tourch:ftObject
	
	Field txtFPS:ftObject
	Field txtMsg:ftObject
	
	Field cw:Float
	Field ch:Float
	
	Field isSuspended:Bool = False
	'Define the Particle System variables and set their initial values
	'They will index to the corresponding string arrays below
	Field isSound:Bool = True
	Field pType:Bool = True
	Field pSize:int = 0
	Field nParticles:Int = 3
	Field pLife:Int = 5
	Field pMode:Bool = True
	Field pColor:Int = 10
	Field pEmitter:Bool = True
		
	
	Field txtParticles:String[] =["10", "25", "50", "100", "250", "500", "750", "1000"]
	Field txtSize:String[] =["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "15", "20", "25"]
	Field txtLife:String[] =["1.0", "1.5", "2.0", "3.0", "3.5", "4.0", "4.5", "5.0", "6.0", "7.0", "8.0"]
	Field txtMode:String[] =["Implode", "Explode"]
	Field txtType:String[] =["Square", "Circle"]
	Field txtSound:String[] =["Off", "On"]
	Field txtColors:String[] =["White", "Red", "Green", "Blue", "Yellow", "Aqua", "Orange", "Brown", "Pink", "Confetti", "Random"]
	Field txtEmitter:String[] =["Off", "On"]
	
	Field sndSelect:ftSound
	Field sndFW:ftSound
	Field sndBubbles:ftSound
	
	Field var:Int[4]
	
	Const btnParticles:Int = 1
	Const btnSound:Int = 2
	Const btnSize:Int = 3
	Const btnLife:Int = 4
	Const btnMode:Int = 5
	Const btnType:Int = 6
	Const btnColor:Int = 7
	Const btnEmitter:Int = 8
	Const taMain:Int = 9
	
	Const strTitle:String = "Particle System for FantonGL"
	
	Method CreateLayers:Int()
		layerBackGround = eng.CreateLayer()
		layerMenu = eng.CreateLayer()
		Return 0
	End
	Method CreateMenuScreen:Int()
		eng.SetDefaultLayer(layerMenu)
		Local t1:= eng.CreateText(font1, strTitle, cw / 2, 30, 1)
		t1.SetScale(1.0)
		t1.SetLayer(layerMenu)
		txtMsg = eng.CreateText(font1, "Click or Touch the Screen", (cw + 160) / 2, ch - 20, 1)
		txtMsg.SetScale(0.5)
		txtMsg.SetLayer(layerMenu)
		Local t1PosY:Int = t1.GetHeight() +t1.GetPosY() +30
		Local gap:Int = 50
		Local menuPosX:Int = 0
		Local bt1:= CreateTextButton(font1, "Particles: " + txtParticles[nParticles], menuPosX, t1PosY, btnParticles, layerMenu)
		Local bt2:= CreateTextButton(font1, "Color: " + txtColors[pColor], menuPosX, t1PosY + gap, btnColor, layerMenu)
		Local bt3:= CreateTextButton(font1, "Size: " + txtSize[pSize], menuPosX, t1PosY + gap * 2, btnSize, layerMenu)
		Local bt4:= CreateTextButton(font1, "Life: " + txtLife[pLife], menuPosX, t1PosY + gap * 3, btnLife, layerMenu)
		Local bt5:= CreateTextButton(font1, "Mode: " + txtMode[pMode], menuPosX, t1PosY + gap * 4, btnMode, layerMenu)
		Local bt6:= CreateTextButton(font1, "Type: " + txtType[pType], menuPosX, t1PosY + gap * 5, btnType, layerMenu)
		Local bt7:= CreateTextButton(font1, "Sound: " + txtSound[isSound], menuPosX, t1PosY + gap * 6, btnSound, layerMenu)
		Local bt8:= CreateTextButton(font1, "Emitter: " + txtEmitter[pEmitter], menuPosX, t1PosY + gap * 7, btnEmitter, layerMenu)
		Local b:ftObject = eng.CreateZoneBox(cw - (bt5.GetWidth()), ch - t1PosY, cw / 2 + bt5.GetWidth(), ch / 2)
		b.SetLayer(layerMenu)
		Return 0
	End
	Method CreateBackgroundScreen:Void()
		txtFPS = eng.CreateText(font1, "FPS:", cw - 40, 30, 1)
		txtFPS.SetScale(0.5)
		txtFPS.SetLayer(layerBackGround)
	End
	Method CreateTouchArea:Void()
		Local touchArea:ftObject = eng.CreateZoneBox(cw - 160, ch - 50, (cw + 160) / 2, (ch + 50) / 2)
'		Local touchArea:ftObject = eng.CreateBox(cw - 180, ch - 50, (cw + 180) / 2, ch / 2 + 50)	'used to debug the touch area
		touchArea.SetTag(taMain)
		touchArea.SetTouchMode(2)	'Set the touch mode to 2=boundingBox. (1=circle)
		touchArea.SetLayer(layerMenu)
		var[0] = touchArea.GetWidth()
		var[1] = touchArea.GetHeight()
		var[2] = touchArea.GetPosX()
		var[3] = touchArea.GetPosY()
	End
	Method CreateTextButton:ftObject(font:ftFont, txt:String, xp:Int, yp:Int, id:Int, layer:ftLayer)
		Local but:ftObject = eng.CreateText(font, txt, xp, yp, 7)
		but.SetTag(id)
		but.SetTouchMode(2)
		but.SetLayer(layer)
		but.SetScale(0.8)
		Return but
	End
	Method CreateColors:Void()
		particolors = particolors.Resize(11)
		For Local i:Int = 0 Until particolors.Length()
				particolors[i] = New Float[3]
		Next
		particolors[0] =[255.0, 255.0, 255.0] 	' White
		particolors[1] =[255.0, 0.0, 0.0]		' Red
		particolors[2] =[0.0, 255.0, 0.0]		' Green
		particolors[3] =[0.0, 0.0, 255.0]		' Blue
		particolors[4] =[255.0, 255.0, 0.0]		' Yellow
		particolors[5] =[0.0, 255.0, 255.0]		' Aqua
		particolors[6] =[255.0, 128.0, 0.0]		' Orange
		particolors[7] =[128.0, 64.0, 0.0]		' Brown
		particolors[8] =[255.0, 0.0, 128.0]		' Pink
		particolors[9] =[255.0, 0.0, 128.0]		' Pink
		particolors[10] =[255.0, 0.0, 128.0]	' Pink
	End
	Method LoadSounds:Int()
		sndFW = eng.LoadSound("sounds/Fireworks2.mp3")
		sndSelect = eng.LoadSound("sounds/select.mp3")
		sndBubbles = eng.LoadMusic("sounds/bubbles.mp3", True)
		Return 0
	End
	Method LaunchParticles:Void(num:Int, mode:Int, life:Float, cx:Int, cy:Int)
		Local color:float[]
		Local mix:Bool = False
		If txtColors[pColor] = "Random"
			color = particolors[Rnd(pColor - 2)]
		ElseIf txtColors[pColor] = "Confetti"
			mix = True
		Else
			color = particolors[pColor]
		EndIf
		ps.addParticles(num, mode, life, cx, cy, color, mix)
		If (isSound)
			sndFW.Play()
		EndIf
	End
	Method SetScreen:Void()
		Local Device:String = GetDeviceName()
		Local Hardware:String = GetDeviceName()
		If Device = "iPhone"
			eng.SetCanvasSize(DeviceWidth(), DeviceHeight())
		Else
			eng.SetCanvasSize(640, 480)
		EndIf
		
		cw = eng.canvasWidth
		ch = eng.canvasHeight
'		Print "Screen Size w:" + cw+" h:" + ch
	End
	Method CreateTourch:Void()
		Local img:Image = LoadImage("images/tourch.png")
		tourch = eng.CreateImage(img, (cw + 160 - img.Width()) / 2, (ch / 2) + img.Height() / 2)
		tourch.SetLayer(layerBackGround)
	End
	Method OnCreate:Int()
		SetUpdateRate(60)
		eng = New engine
		SetScreen()
		LoadSounds()
		'Print "Vol:" + sndBubbles.GetVolume()
		font1 = eng.LoadFont("fonts/bo_font")
		CreateLayers()
		CreateBackgroundScreen()
		CreateMenuScreen()
		CreateColors()
		CreateTouchArea()
		CreateTourch()
		'create the particle blast (Explode/Implode)
		ps = New ParticleSystem()
		'Create the particle emitter system
		pe = New ParticleEmitter(New PVector(cw / 2, 50))
		pe.origin.set(tourch.GetPosX() +tourch.GetWidth() / 2, tourch.GetPosY(), 0)
		pe.SetDotSize(int(g.txtSize[g.pSize]))
		
		sndBubbles.Play()
	
		Return 0
	End
	Method OnUpdate:Int()
		eng.Update()
		If TouchHit(0) Then
			eng.TouchCheck(layerMenu)
		EndIf
		Return 0
	End
	'------------------------------------------
	Method OnRender:Int()
		Cls(0, 0, 0)
		txtFPS.SetText("FPS:" + eng.GetFPS())
		ps.run(pType)
		If pEmitter
			pe.addParticle()
		EndIf
		pe.run()

		SetAlpha(0.2)
		SetColor(0, 0, 255)
		DrawRect(160, 50, cw - 160, ch - 50)
		SetAlpha(1.0)
		eng.Render()
		Return 0
	End
	Method OnResume:Int()
		isSuspended = False
		SetUpdateRate(60)
		Return 0
	End
	Method OnSuspend:Int()
		isSuspended = True
		SetUpdateRate(5)
		Return 0
	End
End
Function Main:Int()
	g = New game
	Return 0
End
Class engine Extends ftEngine
	Method OnObjectRender:Int(obj:ftObject)
		Return 0
	End
	Method OnObjectTouch:Int(obj:ftObject, touchId:Int)
			Select obj.GetTag()
				Case g.taMain
					g.LaunchParticles(Int(g.txtParticles[g.nParticles]), g.pMode, int(g.txtLife[g.pLife]), TouchX(), TouchY())
				Case g.btnParticles
					g.nParticles += 1
					If g.nParticles > g.txtParticles.Length - 1 Then g.nParticles = 0
					g.ps.SetNumParticles(Int(g.txtParticles[g.nParticles]))
					obj.SetText("Particles: " + g.txtParticles[g.nParticles])
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnColor
					g.pColor += 1
					If g.pColor > g.txtColors.Length - 1 Then g.pColor = 0
					obj.SetText("Color: " + g.txtColors[g.pColor])
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnSize
					g.pSize += 1
					If g.pSize > g.txtSize.Length - 1 Then g.pSize = 0
					g.ps.SetDotSize(int(g.txtSize[g.pSize]))
					g.pe.SetDotSize(int(g.txtSize[g.pSize]))
					obj.SetText("Size: " + g.txtSize[g.pSize])
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnLife
					g.pLife += 1
					If g.pLife > g.txtLife.Length - 1 Then g.pLife = 0
					obj.SetText("Life: " + g.txtLife[int(g.pLife)])
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnMode
					If (g.pMode)
						g.pMode = False
						obj.SetText("Mode: " + g.txtMode[0])	'Implode
					Else
						g.pMode = True
						obj.SetText("Mode: " + g.txtMode[1])	'Explode
					EndIf
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnType
					If g.pType
						g.pType = False
						g.pe.SetType(True)
						obj.SetText("Type: " + g.txtType[0])	'Circle
						
					Else
						g.pType = True
						g.pe.SetType(False)
						obj.SetText("Type: " + g.txtType[1])	'Square
					EndIf
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnSound
					If (g.isSound)
						g.isSound = False
						g.sndBubbles.SetPaused(True)
						obj.SetText("Sound: " + g.txtSound[0])
					Else
						g.isSound = True
						g.sndBubbles.SetPaused(False)
						obj.SetText("Sound: " + g.txtSound[1])
					EndIf
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
				Case g.btnEmitter
					If (g.pEmitter)
						g.pEmitter = False
					g.sndBubbles.SetPaused(True)
						obj.SetText("Emitter: " + g.txtEmitter[0])
					Else
						g.pEmitter = True
						g.sndBubbles.SetPaused(False)
						obj.SetText("Emitter: " + g.txtEmitter[1])
					EndIf
					If (g.isSound)
						g.sndSelect.Play()
					EndIf
			End
		Return 0
	End
End





Xaron(Posted 2015) [#11]
I will try it. Probably tomorrow.


SLotman(Posted 2015) [#12]
The (default) Android emulator sucks. Big time.

Try on a real device, or if you don't have one - try BlueStacks.


Arabia(Posted 2015) [#13]

Hi Mark, no I am not.

I don't have an Android device yet. Do you have one? Can you test my app?



Line 35 you are importing fantomEngine. I don't have fantomEngine installed, otherwise I'd test it out for you.


MikeHart(Posted 2015) [#14]
If fantomEngine is involved, please grab the current state from the Github page as it had some problems with GLFW and so I think it could effect Android too.

https://github.com/mikehart66/fantomengine


APC(Posted 2015) [#15]
Ok Guys thank you for your help

I tried running the my app on the Windows Emulator and on the Mac Book emulator (On the Mac the emulator performance is much faster) t I had the same issues on both OSs.
So I got tired and went to Amazon and bought a Sansung Galaxy S5 and it arrived today, I got my app to run on the device.and it is runing well . There are some other issues with the Android that I am fixing .


computercoder(Posted 2015) [#16]
Generally, the Android emulators are really slow or ineffective for testing with. It is better to test using an actual device. Additionally, you may need to test on several different devices too, since no two devices are the same. For instance, my OUYA (obviously) is different from the Google Nexus 7 (original) and my HTC EVO 3DO. All have their issues and may be different issues on each.

Also, watch the version of the OS you are working with. Technically speaking, if you use API13, is *should* work with the newer versions, but there may be something that pops up in a newer API that breaks your code.

Just a couple of things I've learned programming for Android devices. Hope this helps :)


APC(Posted 2015) [#17]
computercoder,

Thank you for the tips, I am used to develop apps for iOS and their environment is very stable including all the simulators, so Android development echo systems is far from what apple offers but the is a problem I have to deal with if I want to to sell my apps on the Google Play.

Right now I am dealing with the screen size to automatically re size the sprites,


Gerry Quinn(Posted 2015) [#18]
I have found the emulator pretty good for puzzle games, and it does have the advantage that you can try different Android versions and screen sizes at zero cost.

But to see how anything animated will play, you do need a real Android.