[SOLVED] love.system.openURL crashes on Android
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
[SOLVED] love.system.openURL crashes on Android
Hi there,
I'm running this in an android app:
success = love.system.openURL( "http://www.google.com" )
and it crashes instantly.
Is this a know problem?
Could not find anything about it.
I'm providing
<uses-permission android:name="android.permission.INTERNET" />
so the permissions seem fine.
Thank you for your help!
I'm running this in an android app:
success = love.system.openURL( "http://www.google.com" )
and it crashes instantly.
Is this a know problem?
Could not find anything about it.
I'm providing
<uses-permission android:name="android.permission.INTERNET" />
so the permissions seem fine.
Thank you for your help!
Last edited by amightydish on Wed May 17, 2017 6:53 am, edited 1 time in total.
- yetneverdone
- Party member
- Posts: 446
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: love.system.openURL crashes on Android
Up. This also happens to me.
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
Re: love.system.openURL crashes on Android
I dug a bit deeper.
The android implementation of openURL looks good to me:
Pretty much in line with the "normal" Android way the internet proposes:
Checking the log output I get this:
Looks like something in liblove.so:love:android:openURL is tripping it up.
Now this is the code run in /common/android.cpp:
Now I'm not very familiar with the whole library/lua/java setup. But could it be throwing up about my java implementation GameActivity not containing openURL but a parent class it extends? (This is due to admob being wedged in there).
Meaning, does this reference adhere to inheritance rules?
Will play with the code and see what I come up with.
The android implementation of openURL looks good to me:
Code: Select all
public static void openURL (String url) {
Log.d ("GameActivity", "opening url = " + url);
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
Code: Select all
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Code: Select all
art/runtime/java_vm_ext.cc:470] native: #09 pc 000cc837 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love7android7openURLERKSs+42)
art/runtime/java_vm_ext.cc:470] native: #10 pc 0011ce45 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love6system9w_openURLEP9lua_State+40)
art/runtime/java_vm_ext.cc:470] native: #11 pc 001d459c /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #13 pc 000cc837 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love7android7openURLERKSs+42)
art/runtime/runtime.cc:404] native: #14 pc 0011ce45 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love6system9w_openURLEP9lua_State+40)
art/runtime/runtime.cc:404] native: #15 pc 001d459c /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #15 pc 000cc837 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love7android7openURLERKSs+42)
art/runtime/runtime.cc:404] native: #16 pc 0011ce45 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love6system9w_openURLEP9lua_State+40)
art/runtime/runtime.cc:404] native: #17 pc 001d459c /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #02 pc 00243857 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_SemWait_REAL+10)
art/runtime/runtime.cc:404] native: #03 pc 00243c4f /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #04 pc 002433cd /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_RunThread+32)
art/runtime/runtime.cc:404] native: #05 pc 0024393b /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #01 pc 00244079 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_Delay_REAL+64)
art/runtime/runtime.cc:404] native: #02 pc 000cff3b /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love5audio6openal5Audio10PoolThread14threadFunctionEv+54)
art/runtime/runtime.cc:404] native: #03 pc 0011ec13 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love6thread3sdl6Thread13thread_runnerEPv+22)
art/runtime/runtime.cc:404] native: #04 pc 002433cd /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_RunThread+32)
art/runtime/runtime.cc:404] native: #05 pc 0024393b /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
art/runtime/runtime.cc:404] native: #01 pc 00244079 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_Delay_REAL+64)
art/runtime/runtime.cc:404] native: #02 pc 0011fff5 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love5video6theora6Worker14threadFunctionEv+188)
art/runtime/runtime.cc:404] native: #03 pc 0011ec13 /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (_ZN4love6thread3sdl6Thread13thread_runnerEPv+22)
art/runtime/runtime.cc:404] native: #04 pc 002433cd /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (SDL_RunThread+32)
art/runtime/runtime.cc:404] native: #05 pc 0024393b /data/app/com.amightydish.sandbox-1/lib/arm/liblove.so (???)
Now this is the code run in /common/android.cpp:
Code: Select all
bool openURL(const std::string &url)
{
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameActivity");
jmethodID openURL= env->GetStaticMethodID(activity, "openURL", "(Ljava/lang/String;)Z");
jstring url_jstring = (jstring) env->NewStringUTF(url.c_str());
env->CallStaticVoidMethod(activity, openURL, url_jstring);
env->DeleteLocalRef(url_jstring);
env->DeleteLocalRef(activity);
return true;
}
Meaning, does this reference adhere to inheritance rules?
Will play with the code and see what I come up with.
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
Re: love.system.openURL crashes on Android
Partially good news.
It works fine in iOS.
Seems like an android specific issue. Closing in on the problem...
It works fine in iOS.
Seems like an android specific issue. Closing in on the problem...
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
Re: love.system.openURL crashes on Android
So it's what I suspected.
<code>
JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.NoSuchMethodError: no static method "Lorg/love2d/android/GameActivity;.openURL(Ljava/lang/String;)Z"
</code>
The AdMob changes I'm using are not compatible with the love binaries.
Two ways to go about it:
1. recompile the binaries to point to the java class (GameActivityOriginal)
2. adapt the java changes by reshuffling a bit of code
I'm going for #2.
<code>
JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.NoSuchMethodError: no static method "Lorg/love2d/android/GameActivity;.openURL(Ljava/lang/String;)Z"
</code>
The AdMob changes I'm using are not compatible with the love binaries.
Two ways to go about it:
1. recompile the binaries to point to the java class (GameActivityOriginal)
2. adapt the java changes by reshuffling a bit of code
I'm going for #2.
- master both
- Party member
- Posts: 262
- Joined: Tue Nov 08, 2011 12:39 am
- Location: Chile
Re: love.system.openURL crashes on Android
Hi, I'm the creator of the admob extension and I can confirm that this issue is present only in my implementation, I made a quick small fix to the repo now that may or not solve the problem and/or break everything . Sadly I can't debug the problem right now, if the quick fix doesn't work, expect it working tomorow when I have more time.
EDIT:
EDIT:
the changes I made are #1amightydish wrote: ↑Fri May 12, 2017 10:43 pm So it's what I suspected.
<code>
JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.NoSuchMethodError: no static method "Lorg/love2d/android/GameActivity;.openURL(Ljava/lang/String;)Z"
</code>
The AdMob changes I'm using are not compatible with the love binaries.
Two ways to go about it:
1. recompile the binaries to point to the java class (GameActivityOriginal)
2. adapt the java changes by reshuffling a bit of code
I'm going for #2.
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
Re: love.system.openURL crashes on Android
Hey master both, thanks for looking at this!
I'm not in a crazy rush.
Just tried to shuffle the java around, but it's not straight forward, as I need a static reference to the context (with probably all sorts of implications). So I'm quite happy to wait for a better solution.
Looking at the code, I'd suspect at least one other function not to work as well (had no time to test, though)
android.cpp:vibrate() wants a -> org/love2d/android/GameActivity.vibrate()
I think the original love functions try to find the activity class by name.
Bad!
The admob related ones go a different, less hard wired route.Good!
So your new ones seem adaptable, just the original functions would have to be updated to the same mechanism.
Thanks again!
I'm not in a crazy rush.
Just tried to shuffle the java around, but it's not straight forward, as I need a static reference to the context (with probably all sorts of implications). So I'm quite happy to wait for a better solution.
Looking at the code, I'd suspect at least one other function not to work as well (had no time to test, though)
android.cpp:vibrate() wants a -> org/love2d/android/GameActivity.vibrate()
I think the original love functions try to find the activity class by name.
Code: Select all
jclass activity = env->FindClass("org/love2d/android/GameActivityOriginal");
The admob related ones go a different, less hard wired route.
Code: Select all
env->GetObjectClass(activity)
So your new ones seem adaptable, just the original functions would have to be updated to the same mechanism.
Thanks again!
- master both
- Party member
- Posts: 262
- Joined: Tue Nov 08, 2011 12:39 am
- Location: Chile
Re: love.system.openURL crashes on Android
Ok, after some debugging I finally found the problem... the jni implementation of openURL had a bad return value in it's signature:
Should have been:
This have been fixed on my repo.
Code: Select all
jmethodID openURL= env->GetStaticMethodID(clazz, "openURL", "(Ljava/lang/String;)Z");
Code: Select all
jmethodID openURL= env->GetStaticMethodID(clazz, "openURL", "(Ljava/lang/String;)V"); <-- (notice the V here)
- yetneverdone
- Party member
- Posts: 446
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: love.system.openURL crashes on Android
Cool. To update repo,master both wrote: ↑Sun May 14, 2017 3:44 am Ok, after some debugging I finally found the problem... the jni implementation of openURL had a bad return value in it's signature:Should have been:Code: Select all
jmethodID openURL= env->GetStaticMethodID(clazz, "openURL", "(Ljava/lang/String;)Z");
This have been fixed on my repo.Code: Select all
jmethodID openURL= env->GetStaticMethodID(clazz, "openURL", "(Ljava/lang/String;)V"); <-- (notice the V here)
git pull works right?
Then do i have to rebuild the repo with ndk-build again?
EDIT:
Yes, git pull and ndk-build is a must
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
- amightydish
- Prole
- Posts: 11
- Joined: Fri May 12, 2017 5:18 pm
Re: love.system.openURL crashes on Android
I just found the time to test this and it works! Awesome!
Thank you for your quick help!
Thank you for your quick help!
Who is online
Users browsing this forum: Google [Bot] and 61 guests