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

Post fix to 'file exposed beyond app' error #10

Closed
ThomasCWright opened this issue Nov 23, 2020 · 6 comments
Closed

Post fix to 'file exposed beyond app' error #10

ThomasCWright opened this issue Nov 23, 2020 · 6 comments
Labels

Comments

@ThomasCWright
Copy link
Owner

Used https://stackoverflow.com/q/38983649/7312441 as starting point, however, following error thrown

11-23 12:09:14.323 23238 5039 I python : jnius.jnius.JavaException: JVM exception occurred: file:///./blank_9x9.png exposed beyond app through ClipData.Item.getUri()

Originally posted by @ThomasCWright in #1 (comment)

@ThomasCWright
Copy link
Owner Author

OK, so here I will use pip install python-for-android version of p4a and resolve this issue in the same manner as this post kivy/plyer#500 (comment)

@ThomasCWright
Copy link
Owner Author

Cancel that as this depends on installing support-v4-24.1.1.aar for which I can't easily find an official source.

Now reverting back forking PR on p4a which fixes this problem and is mentioned later in the same issue here with commandline args here

@ThomasCWright
Copy link
Owner Author

ThomasCWright commented Nov 24, 2020

forked

  • Deactivate any conda env
  • Compile master and pass tests
  • Install resulting package
  • Check builds same as pip installed version
  • Checkout branch FileProvider and repeat
    Struggling: just installed downgrade of $ANDROIDNDK
    Will compile again:

image

@ThomasCWright
Copy link
Owner Author

  • Some progress. merged fork onto most recent develop and compiled and re-installed p4a in venv
  • Full clean of ~/.local/share/python-for-android
  • p4a apk --private . --package=com.chdirections --name "myapp" --version 0.1 --bootstrap=sdl2 --requirements=python3,kivy,pyjnius --arch=arm64-v8a --android_api=27 --fileprovider-paths=./mypaths.xml now works and produces an apk 🍾🍾
  • adb logcat | grep python gives following error:
    image

@ThomasCWright
Copy link
Owner Author

ThomasCWright commented Nov 25, 2020

Installed very useful tool androguard which delivers all manner of tools to inspect an apk
kudos for this bugfix androguard/androguard#769 (comment)
Hence, installation is actually pip install git+https://github.com/androguard/androguard.git

(kivy) C:\> androguard axml unnamed_dist_1__arm64-v8a-debug-0.1-.apk gives following result:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="8211" android:versionName="0.1" android:installLocation="0" package="com.chdirections" platformBuildVersionCode="8211" platformBuildVersionName="0.100000">
  <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="27"/>
  <supports-screens android:anyDensity="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true"/>
  <uses-feature android:glEsVersion="0x00020000"/>
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <application android:theme="@android:01030007" android:label="@7F090000" android:icon="@7F050001" android:debuggable="true" android:allowBackup="true" android:hardwareAccelerated="true">
    <meta-data android:name="wakelock" android:value="0"/>
    <activity android:label="@7F090000" android:name="org.kivy.android.PythonActivity" android:launchMode="2" android:screenOrientation="1" android:configChanges="0x40002FFF">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <provider android:name="android.support.v4.content.FileProvider" android:exported="false" android:authorities="com.chdirections.fileprovider" android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@7F0C0000"/>
    </provider>
    <meta-data android:name="android.support.VERSION" android:value="26.1.0"/>
    <meta-data android:name="android.arch.lifecycle.VERSION" android:value="27.0.0-SNAPSHOT"/>
  </application>
</manifest>

The above shows that although p4a is accepting arguments to define paths & FileProvider capabilities, they are not being inserted correctly into the apk.

One last try with a better path definition for file_paths:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="my_images" path="images/"/>
</paths>

Same problem. Checking the AndroidManifest.xml in ....src/main seems as though it looks half reasonable.

        <provider android:name="android.support.v4.content.FileProvider"
                  android:authorities="com.chdirections.fileprovider"
                  android:exported="false"
                  android:grantUriPermissions="true">
          <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
                     android:resource="@xml/file_paths" />
        </provider>

This rabbit hole is currently too deep although learnt much on android ..etc. Pausing for now and seeking another solution to the problem without file handling.
Kicking to short grass as solution may be useful to me & community.

@ThomasCWright
Copy link
Owner Author

Avoided FileProvider by saving the image to an externally accessible storage area so that Intent could be shared with printing app.

Creating new issue specifically for implementation of FileProvider as this will still be useful.

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

No branches or pull requests

1 participant