Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webview app crashes when trying to request permissions #2325

Closed
5 tasks done
frnsys opened this issue Sep 27, 2020 · 3 comments · Fixed by #2340
Closed
5 tasks done

Webview app crashes when trying to request permissions #2325

frnsys opened this issue Sep 27, 2020 · 3 comments · Fixed by #2340

Comments

@frnsys
Copy link

frnsys commented Sep 27, 2020

Checklist

  • the issue is indeed a bug and not a support request
  • issue doesn't already exist: https://github.com/kivy/python-for-android/issues
  • I have a short, runnable example that reproduces the issue
  • I reproduced the problem with the latest development version (p4a.branch = develop)
  • I used the grave accent (aka backticks) to format code or logs when appropriated

Versions

  • Python: 3.6.6
  • OS: Ubuntu 20.04
  • python-for-android: 2020.6.2

Description

I'm building with:

HERE=$(pwd)
cd app

export ANDROIDSDK="$HERE/android_sdks"
# Have also tried with
# export ANDROIDNDK="$HERE/android_sdks/android-ndk-r19c"
export ANDROIDNDK="$HERE/android_sdks/android-ndk-r21d"
export ANDROIDAPI="27"  # Target API version of your application
export NDKAPI="21"  # Minimum supported API version of your application

p4a apk --private "." --package=org.anarres.pdfreader --name "pdf reader" --version 0.1 --bootstrap=webview --requirements=python3,flask --port=5000 --orientation=sensor --blacklist="../blacklist.txt" --permission READ_EXTERNAL_STORAGE --permission WRITE_EXTERNAL_STORAGE

My python code is just:

from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
    app.run(port=5000)

If I comment out:

from android.permissions import request_permissions, Permission
request_permissions([Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE])

I don't see the error, but then of course I can't access the external storage.

Logs

ImportError: dlopen failed: cannot locate symbol "SDL_ANDROID_GetJNIEnv" referenced by "/data/data/org.anarres.pdfreader/files/app/_python_bundle/site-packages/android/_android.so"...
@mnba
Copy link

mnba commented Sep 28, 2020

Seems the code in your linked _android.so library by some reason requests SDL_xxx functions while they are not built in, as your bootstrap is webview, and hence the code you built has no SDL functions in it

@frnsys
Copy link
Author

frnsys commented Sep 28, 2020

Yeah, references to SDL_Android_GetJNIEnv are hard coded in the library: https://github.com/kivy/python-for-android/search?q=SDL_Android_GetJNIEnv. I tried replacing it wherever it shows up with WebView_AndroidGetJNIEnv (which appears to be defined here?) but that led to a similar error:

ImportError: dlopen failed: cannot locate symbol "WebView_AndroidGetJNIEnv" referenced by "/data/data/org.anarres.pdfreader/files/app/_python_bundle/site-packages/android/_android.so"...

@obfusk
Copy link
Contributor

obfusk commented Oct 20, 2020

@frnsys I think I managed to fix this in #2340.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants