jacklinquan / usbserial4a

Python package for Android USB host serial port.
MIT License
60 stars 17 forks source link

Cannot build app: Missing device_filter.xml resource #16

Open ham-a7 opened 9 months ago

ham-a7 commented 9 months ago

It seems that this package does not work when following the readme build instructions. I noticed it said "these instructions are out of date and need updating" so I thought I would raise an issue. I am new to building apps with Buildozer so sorry if the package is working and I am just getting something wrong.

I cannot build the usbserial4a_ui_example.py example app into an APK file.

I follow the readme: I update the buildozer.spec file and add the intent-filter.xml file to the project folder. The build then fails as expected giving the error that is cannot find the device_filter.xml file (which I haven't added yet).

I then create an xml folder in the specified directory and add the the device_filter.xml to it.

However when I build the app it gives the same error; it cannot find the device_filter.xml file.

The error is:

Android resource linking failed
ERROR: /home/ham/Projects/usbserial/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/dists/myapp/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:65: AAPT: error: resource xml/device_filter (aka org.test.myapp:xml/device_filter) not found.

Deviations I made from the instructions:

Here is my AndroidManifest.tmpl.xml file so you can see where I have added the <uses-feature android:name="android.hardware.usb.host" /> line:

<?xml version="1.0" encoding="utf-8"?>
<!-- Replace org.libsdl.app with the identifier of your game below, e.g.
     com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="{{ args.package }}"
      android:versionCode="{{ args.numeric_version }}"
      android:versionName="{{ args.version }}"
      android:installLocation="auto">

    <supports-screens
            android:smallScreens="true"
            android:normalScreens="true"
            android:largeScreens="true"
            android:anyDensity="true"
            {% if args.min_sdk_version >= 9 %}
            android:xlargeScreens="true"
            {% endif %}
    />

    <!-- Android 2.3.3 -->
    <uses-sdk android:minSdkVersion="{{ args.min_sdk_version }}" android:targetSdkVersion="{{ android_api }}" />

    <!-- OpenGL ES 2.0 -->
    <uses-feature android:glEsVersion="0x00020000" />
    <uses-feature android:name="android.hardware.usb.host" />

    <!-- Set permissions -->
    {% for perm in args.permissions %}
        <uses-permission android:name="{{ perm.name }}"{% if perm.maxSdkVersion %} android:maxSdkVersion="{{ perm.maxSdkVersion }}"{% endif %}{% if perm.usesPermissionFlags %} android:usesPermissionFlags="{{ perm.usesPermissionFlags }}"{% endif %} />
    {% endfor %}

    {% if args.wakelock %}
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    {% endif %}

    {% if args.billing_pubkey %}
    <uses-permission android:name="com.android.vending.BILLING" />
    {% endif %}

    {{ args.extra_manifest_xml }}

    <!-- Create a Java class extending SDLActivity and place it in a
         directory under src matching the package, e.g.
            src/com/gamemaker/game/MyGame.java

         then replace "SDLActivity" with the name of your class (e.g. "MyGame")
         in the XML below.

         An example Java class can be found in README-android.txt
    -->
    <application android:label="@string/app_name"
                 {% if debug %}android:debuggable="true"{% endif %}
                 android:icon="@mipmap/icon"
                 android:allowBackup="{{ args.allow_backup }}"
                 {% if args.backup_rules %}android:fullBackupContent="@xml/{{ args.backup_rules }}"{% endif %}
                 {{ args.extra_manifest_application_arguments }}
                 android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}"
                 android:hardwareAccelerated="true"
                 android:extractNativeLibs="true" >
        {% for l in args.android_used_libs %}
        <uses-library android:name="{{ l }}" />
        {% endfor %}

        {% for m in args.meta_data %}
        <meta-data android:name="{{ m.split('=', 1)[0] }}" android:value="{{ m.split('=', 1)[-1] }}"/>{% endfor %}
        <meta-data android:name="wakelock" android:value="{% if args.wakelock %}1{% else %}0{% endif %}"/>

        <activity android:name="{{args.android_entrypoint}}"
                  android:label="@string/app_name"
                  android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode{% if args.min_sdk_version >= 8 %}|uiMode{% endif %}{% if args.min_sdk_version >= 13 %}|screenSize|smallestScreenSize{% endif %}{% if args.min_sdk_version >= 17 %}|layoutDirection{% endif %}{% if args.min_sdk_version >= 24 %}|density{% endif %}"
                  android:screenOrientation="{{ args.manifest_orientation }}"
                  android:exported="true"
                  {% if args.activity_launch_mode %}
                  android:launchMode="{{ args.activity_launch_mode }}"
                  {% endif %}
                  >

            <intent-filter>
            {% if args.launcher %}            
                <action android:name="org.kivy.LAUNCH" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="{{ url_scheme }}" />
            {% else  %}
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            {% endif %}

            {% if args.home_app %}
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            {% endif %}
            </intent-filter>

            {%- if args.intent_filters -%}
            {{- args.intent_filters -}}
            {%- endif -%}
        </activity>

        {% if args.launcher %}
        <activity android:name="org.kivy.android.launcher.ProjectChooser"
                  android:icon="@mipmap/icon"
                  android:label="@string/app_name"
                  android:exported="true">

          <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>

        </activity>
        {% endif %}

        {% if service or args.launcher %}
        <service android:name="{{ args.service_class_name }}"
                 android:process=":pythonservice" />
        {% endif %}
        {% for name in service_names %}
        <service android:name="{{ args.package }}.Service{{ name|capitalize }}"
                 android:process=":service_{{ name }}" />
        {% endfor %}
        {% for name in native_services %}
        <service android:name="{{ name }}" />
        {% endfor %}

        {% if args.billing_pubkey %}
        <service android:name="org.kivy.android.billing.BillingReceiver"
                 android:process=":pythonbilling" />
        <receiver android:name="org.kivy.android.billing.BillingReceiver"
                  android:process=":pythonbillingreceiver"
                  android:exported="false">
            <intent-filter>
                <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />
                <action android:name="com.android.vending.billing.RESPONSE_CODE" />
                <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />
            </intent-filter>
        </receiver>
        {% endif %}
    {% for a in args.add_activity  %}
    <activity android:name="{{ a }}"></activity>
    {% endfor %}
    </application>

</manifest>