Build fails while using an extension with UsesServices annotation

I checked out Kodular Fenix (v1.5.0) Bug Tracker before creating a new topic

Describe your issue

Extensions which use a UsesServices annotation fail during building the project, the error message is YAIL compiler - AAPT execution failed.

example: NotificationListener extension (free and open source)

@UsesServices(services = {
    @ServiceElement(
        name = "com.puravidaapps.TaifunNotificationListener.TaifunNotificationListener$NotificationService", 
	    label = "NotificationService", 
   	    permission = "android.permission.BIND_NOTIFICATION_LISTENER_SERVICE", 
	    intentFilters = {
	        @IntentFilterElement(actionElements = {@ActionElement(name = "android.service.notification.NotificationListenerService")
 	    })
    })      
})

Steps to reproduce the issue

create an empty project, add the notification listener extension downloadable from here App Inventor Extensions: Notification Listener | Pura Vida Apps and build the project

Expected Behaviour

build terminates successfully

Actual Behaviour

build terminates with error message YAIL compiler - AAPT execution failed.

Show your Blocks

no blocks necessary to elicit the error

Android version

not relevant to the issue

Taifun

3 Likes

I guess Kodular has still not added the UsesService annotation?

3 Likes

Your test project builds just fine but there is still a issue when importing aia project from MIT…

Edit: some other issues when importing.

  • RTL support (You have to check uncheck in settings to get it to work in live test)

  • Splash screen (You have to check uncheck in settings to get it to work in live test)

  • Min sdk is missing

1 Like

thank you @Boban for your test…

yes (this is funny), an empty project together with the extension does not build (see bug report), but my test project created with MIT App Inventor builds fine after setting theme Default in the project settings…

however after examining the manifest of the apk file using APK Editor Studio, the required service tag is missing in the manifest… so as @Xoma was guessing correctly, Kodular still does not add the UsesServices annotation…

        <service android:label="NotificationService" android:name="com.puravidaapps.TaifunNotificationListener.TaifunNotificationListener$NotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService"/>
            </intent-filter>
        </service>
Manifest after Kodular build <?xml version="1.0" encoding="utf-8" standalone="no"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="nls" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="false" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name="io.kodular.taifunbaer.nls.Screen1" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <meta-data android:name="io.kodular.app.VERSION" android:value="1.5.1-Fenix"/>
    <provider android:authorities="io.kodular.taifunbaer.nls.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
Manifest after MIT App Inventor build <?xml version="1.0" encoding="utf-8" standalone="no"?>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application android:debuggable="false" android:icon="@mipmap/ic_launcher" android:label="nls" android:name="com.google.appinventor.components.runtime.multidex.MultiDexApplication" android:networkSecurityConfig="@xml/network_security_config" android:requestLegacyExternalStorage="true" android:roundIcon="@mipmap/ic_launcher" android:theme="@style/AppTheme">
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" android:name=".Screen1" android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <service android:label="NotificationService" android:name="com.puravidaapps.TaifunNotificationListener.TaifunNotificationListener$NotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
        <intent-filter>
            <action android:name="android.service.notification.NotificationListenerService"/>
        </intent-filter>
    </service>
    <provider android:authorities="appinventor.ai_taifunbaer.nls.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
        <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/>
    </provider>
</application>

Taifun

2 Likes

Right. We have the necessary changes ready but it was blocked due to conditional permissions (permissions per method).

1 Like