OpenURL crashing

Monkey Targets Forums/Android/OpenURL crashing

pantson(Posted 2014) [#1]
Hi
My latest game (far too much code to post) crashes when using OpenUrl(url). It looks like it cant find an activity. URL = http://play.google.com/store/apps/details?id=com.appytimes.gpcz
Here is the crash
I/[Monkey]( 7800): http://play.google.com/store/apps/details?id=com.appytimes.gpcz
E/AndroidRuntime( 7800): FATAL EXCEPTION: main
E/AndroidRuntime( 7800): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= http://play.google.com/store/apps/details?id=com.appytimes.gpcz }
E/AndroidRuntime( 7800): 	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
E/AndroidRuntime( 7800): 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
E/AndroidRuntime( 7800): 	at android.app.Activity.startActivityForResult(Activity.java:3190)
E/AndroidRuntime( 7800): 	at android.app.Activity.startActivity(Activity.java:3297)
E/AndroidRuntime( 7800): 	at com.appytimes.gpcz.BBAndroidGame.OpenUrl(MonkeyGame.java:1142)

and here is the manifest file
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="com.appytimes.gpcz"
	android:versionCode="16"
	android:versionName="4.55"
	android:installLocation="auto">
	
	<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="7" />
	
	<uses-feature android:glEsVersion="0x00010001" />

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

	<uses-permission android:name="com.android.vending.BILLING" />
		
	<application android:label="Clone Zoo HD Giraffic Park" android:icon="@drawable/icon">
	
		<activity 
			android:name="MonkeyGame"
			android:label="Clone Zoo HD Giraffic Park"
			android:screenOrientation="portrait"
			android:configChanges="keyboardHidden|orientation|screenSize"
			android:theme=\"@..."
			android:launchMode="singleTop">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
		
		<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
		
	</application>
</manifest> 


Weirdly I have written a small app that does work. I am doing no different in the above game.. just a lot more code and gfx
code
Strict

Import mojo
Import pantson
Import brl.admob

Function Main:Int()
	New AdTest()
	
	Return 0
End Function

Class AdTest Extends App
	Const FPS:=30
	Field timer:DeltaTimer
	
	Const game_width:=400
	Field scale:Float
	Field game_height:Float
	
	Field img:Image
	
	Field ad:Admob
	
	Method OnCreate:Int()
	    SetUpdateRate(FPS)
		timer = New DeltaTimer(FPS)
		
		scale=DeviceWidth()/Float(game_width)
		game_height=DeviceHeight()*scale
		
			ad=New Admob
			ad.ShowAdView(5,5)
	    Return True
	End Method

	Method OnUpdate:Int()
		Local t:Int
		
		timer.UpdateDelta()
		
		t=0
		While t<timer.loop	
			If MouseHit(MOUSE_LEFT)
				OpenUrl("http://www.google.com")
			End
			t=t+1
		Wend
	    
		' fix delta
		timer.delta = timer.delta - t		

		Return True
	End Method
  
	Method OnRender:Int()
	    PushMatrix()
	    Cls()
		Scale scale,scale
		
		DrawText("device width = "+DeviceWidth()+" "+Millisecs(),10,30)
		
	    PopMatrix()
	
	    Return True
	End Method
End Class

manifest
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	package="com.monkeycoder.monkeygame"
	android:versionCode="1"
	android:versionName="1.0"
	android:installLocation="auto">
	
	<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="7" />
	
	<uses-feature android:glEsVersion="0x00010001" />

	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
	
		
	<application android:label="Monkey Game" android:icon="@drawable/icon">
	
		<activity 
			android:name="MonkeyGame"
			android:label="Monkey Game"
			android:screenOrientation="user"
			android:configChanges="keyboardHidden|orientation|screenSize"
			android:theme=\"@..."
			android:launchMode="singleTop">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>
		</activity>
		
		<activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
		
	</application>
</manifest> 


I have tried everything and even tried my own launchurl() in java which produces the same error.

has anyone else seen this before?
many thanks for looking

update 1 : just noticed that I do use billing in the game but not in the test app. Does this make a difference?


SLotman(Posted 2014) [#2]
Have you tried using the same URL that crashes in the program that works? Maybe the string needs to be URLEncoded? (I'm guessing, no idea really what is going on)


pantson(Posted 2014) [#3]
yeah tried that
ta


SLotman(Posted 2014) [#4]
Tried what? The URL that crashes in the program that works? If that worked, then your problem may lie somewhere else than openurl...
The URLEncode? I would recommend to try both.

WAIT!

Why you're doing this:
While t<timer.loop	
			If MouseHit(MOUSE_LEFT)
				OpenUrl("http://www.google.com")
			End
			t=t+1
		Wend


There is no need for a loop! Just check if mousehit() and remove that while...wend!


pantson(Posted 2014) [#5]
I tried using the same url for both apps. One app worked the other didn't.
The loop is there to fix delta timing. its not that (I hope).. both apps have this fix in it.

The error log does point to the OpenUrl command as thats the last monkey function to be called before android beefs
I/[Monkey]( 7800): http://play.google.com/store/apps/details?id=com.appytimes.gpcz
E/AndroidRuntime( 7800): FATAL EXCEPTION: main
E/AndroidRuntime( 7800): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= http://play.google.com/store/apps/details?id=com.appytimes.gpcz }
E/AndroidRuntime( 7800): 	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
E/AndroidRuntime( 7800): 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
E/AndroidRuntime( 7800): 	at android.app.Activity.startActivityForResult(Activity.java:3190)
E/AndroidRuntime( 7800): 	at android.app.Activity.startActivity(Activity.java:3297)
E/AndroidRuntime( 7800): 	at com.appytimes.gpcz.BBAndroidGame.OpenUrl(MonkeyGame.java:1142)

I'm not sayaing its not me ;-)
I cant find the android.intent.action.VIEW in the manifest file.. is this created on the fly by monkey or am i missing something?


therevills(Posted 2014) [#6]
In the application which is crashing, start removing code until it works and then try to write a small example with the same code that fails.


pantson(Posted 2014) [#7]
I've got a lot of removing to do ;-)


SLotman(Posted 2014) [#8]

The loop is there to fix delta timing.



Why would you need a "fix delta timing" for user input?! That makes no sense... you are probably trying to open the same URL multiple times!

Since google is a lightweight page, it may succeed - but google play tries to open the store link - which is way heavier... and multiple times, may not be able to create another view due to lack of memory.

I'll say it again: remove that loop. Its not necessary and probably the cause of your problem.


pantson(Posted 2014) [#9]
FIXED.

TBH I'm not sure what the issue was.

I ripped the code apart till it started working and have now put all the code back to how it was.
I have really not changed any code... theres some indenting and comment diffs but thats about it.

I did change form emulator to physical device halfway through, maybe that was it. I'll investigate more (currently working on ICS physical)

I'll test in various levels of Android

Thanks for all the help and advice.
Will have a look at my code as you're right theres no need for delta timing on user input.. that was the test code that worked originally ;-)

I'm just going to put this to "one of those days"