Android Question [SOLVED] MediaChooser shortService is not recognized

fbritop

Well-Known Member
Licensed User
Longtime User
Hi
I´m using the example for Media Chooser from:

When I try to compile it throws an error:

AndroidManifest.xml:55: error: 'shortService' is incompatible with attribute foregroundServiceType (attr) flags [camera=64, connectedDevice=16, dataSync=1, location=8, mediaPlayback=2, mediaProjection=32, microphone=128, phoneCall=4].
error: failed processing manifest.


Using B4A 13 release
The latest SDK and Android Resources

Manifest (updated for SDK 34)

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
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" />
)
SetServiceAttribute(KeepRunningService, android:foregroundServiceType, shortService)

Libs: ExoPlayer 3.02
Media Chooser: 1.02
SimpleMediaManager: 1.17
b4xGifView: 1.12

Not sure why it does not recognize "shortService" as valid. What am I missing here?

Thanks
FBP
 

fbritop

Well-Known Member
Licensed User
Longtime User
post your androidmanifest.xml from the objects folder
AndroidManifest.xml:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="b4a.example"
    android:versionCode="1"
    android:versionName=""
    android:installLocation="internalOnly">
    
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33"/>
    <supports-screens android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:anyDensity="true"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <application
        android:name="androidx.multidex.MultiDexApplication"
        android:icon="@drawable/icon"
        android:label="B4A Example"
        android:theme="@style/LightTheme">
        
        <provider
          android:name="androidx.core.content.FileProvider"
          android:authorities="b4a.example.provider"
          android:exported="false"
          android:grantUriPermissions="true">
          <meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/provider_paths"/>
          </provider>
        <activity
            android:windowSoftInputMode="stateHidden"
            android:launchMode="singleTop"
            android:name=".main"
            android:label="B4A Example"
            android:screenOrientation="portrait"
            android:exported="true">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
        </activity>
        <service
            android:name=".starter"
            android:exported="true">
        </service>
        <receiver
            android:name=".starter$starter_BR"
            android:exported="true">
        </receiver>
        <service
            android:name=".keeprunningservice"
            android:exported="true">
        </service>
        <receiver
            android:name=".keeprunningservice$keeprunningservice_BR"
            android:exported="true">
        </receiver>
    </application>
</manifest>
 
Upvote 0

fbritop

Well-Known Member
Licensed User
Longtime User
Hi
I´m using the example for Media Chooser from:

When I try to compile it throws an error:

AndroidManifest.xml:55: error: 'shortService' is incompatible with attribute foregroundServiceType (attr) flags [camera=64, connectedDevice=16, dataSync=1, location=8, mediaPlayback=2, mediaProjection=32, microphone=128, phoneCall=4].
error: failed processing manifest.


Using B4A 13 release
The latest SDK and Android Resources

Manifest (updated for SDK 34)

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
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" />
)
SetServiceAttribute(KeepRunningService, android:foregroundServiceType, shortService)

Libs: ExoPlayer 3.02
Media Chooser: 1.02
SimpleMediaManager: 1.17
b4xGifView: 1.12

Not sure why it does not recognize "shortService" as valid. What am I missing here?

Thanks
FBP
Thanks
It was solved. Somewhere I have an script to backup my B4A configuration files, it somehow overwrite the SDK Paths pointing to the old 33 SDK Version.
 
Upvote 0
Top