Android Question [Resolved]File Provaider error

ivanomonti

Expert
Licensed User
Longtime User
I took a cue from @Erel post but without success :-(

Android 11
Galaxy A10


Manifest:
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)


code for share txt:
        Dim FileToSend As String = "Message.txt"
        File.WriteString(Provider.SharedFolder, FileToSend, m.Get("ms_gpt_01_05"))
        Dim in As Intent
        in.Initialize(in.ACTION_SEND, "")
        in.SetType("text/plain")
        in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
        in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
        StartActivity(in)

compilation error

Error:
B4A Versione: 12.20
Analisi del Codice.    (0.17s)
    Java Versione: 14
Building folders structure.    (0.07s)
Esecuzione azione personalizzata.    (0.06s)
Compilazione del codice.    (0.46s)
Compilazione del codice di layouts    (0.01s)
Organizzazione Librerie.    (0.00s)
    (AndroidX SDK)
Compilazione risorse    (0.24s)
Collegamento risorse    Error
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:112: error: resource android:attr/lStar not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:162: error: resource android:attr/fontStyle not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:163: error: resource android:attr/font not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:164: error: resource android:attr/fontWeight not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:165: error: resource android:attr/fontVariationSettings not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:166: error: resource android:attr/ttcIndex not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:190: error: resource android:attr/startX not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:192: error: resource android:attr/startY not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:194: error: resource android:attr/endX not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:196: error: resource android:attr/endY not found.
c:\android\tools\..\extras\b4a_remote\androidx\core\core\1.9.0\unpacked-core-1.9.0\res\values\values.xml:203: error: resource android:attr/offset not found.
error: failed linking references.
 

ivanomonti

Expert
Licensed User
Longtime User
Delete your Android SDK and download the two components listed here: https://www.b4x.com/b4a.html

hello @Erel thanks for the reply, this morning I threw away all the previous installations in fact there were fragments of libraries and java from 2012 :-( which created conflicts, I deleted b4a and b4j which were installed in the 86x programs folder as the new ones are in programs, in short, I had a mess that I cleaned up by resetting everything.

Now the FileProvider library compiles and without problems but it crashes here

error:
java.io.FileNotFoundException: Message.txt: open failed: EROFS (Read-only file system)

Line Error: File.WriteString(Provider.SharedFolder, FileToSend, m.Get("ms_gpt_01_05"))

code:
    If Index = 1 Then 'share
        Dim Provider As FileProvider
        Dim FileToSend As String = "Message.txt"
        File.WriteString(Provider.SharedFolder, FileToSend, m.Get("ms_gpt_01_05")) ' ms_gpt_01_05 = result txt
        Dim in As Intent
        in.Initialize(in.ACTION_SEND, "")
        in.SetType("text/plain")
        in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
        in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
        StartActivity(in)
    End If


Manifest:
AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
 
Upvote 0
Top