How do I reference an image in Android manifest file?

From the Asset Store
Source File, music and art pack for Android Negotiator
  • I am trying to make a TV-compatible app, following these guidelines from Google:

    developer.android.com/training/tv/start/start

    One of the requirements is a home screen banner:

    <application
     ...
     android:banner="@drawable/banner" >
    
     ...
    </application>
    

    If I include banner image in Files or Icons folder in the C3 project, how do I reference it correctly in the manifest?

    I'm building with Cordova CLI, so maybe another option is to somehow add the banner file after exporting the project?

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Manually

    Maybe it's possible to hardcode the location in your manifest after exporting the C3 project, if you can find this folder res/drawable/, then in the manifest you could put the image inside res/drawable/filename.png and try replacing in the manifest @drawable/banner with res/drawable/filename.png or @drawable/filename.png.

    C3 Files

    If you want to do it via C3, you can upload a file to Files in C3, it will be located directly in exported www\filename.png. You can try to reference that image from the exported folder by replacing @drawable/banner with www\filename.png, there's a possibility that it needs to be served via protocol like: http:\\www\filename.png

    Or the syntax could be @drawable/www/filename.png. Their docs are kind of weird so I'm guessing a bit here.

    https://developer.android.com/guide/topics/resources/drawable-resource#Bitmap

    I hope this helps in any form further, otherwise, at least the post got bumped a bit :)

  • I managed to build an app that works on TV and displays its icon in the Android TV Launcher. Google Play Store should allow this app to be installed on TVs, although I haven't tried it.

    Decided to leave the instructions here in case anyone else needs it. Not sure if my method is 100% correct, but hey, it works!

    1.

    Export your project for Android, choose "Cordova project" build type.

    2.

    Add this tag to the config.xml file:

    <preference name="AndroidXEnabled" value="true" />

    3.

    In Cordova CLI execute "cordova prepare" command.

    4.

    Make the following changes to \platforms\android\app\src\main\AndroidManifest.xml

    4.1.

    Add android:banner attribute to <application>:

    <application android:banner="@drawable/banner" ... >

    4.2.

    Replace android:theme attribute in <activity> tag:

    <activity .... android:theme="@style/Theme.Leanback" ... >

    4.3.

    Add a new intent-filter to the activity:

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

    4.4.

    Add these two keys to the root <manifest> tag:

    <uses-feature android:name="android.software.leanback" android:required="false" /> <uses-feature android:name="android.hardware.touchscreen" android:required="false" />

    Here is what the result should look like:

    5.

    Edit \platforms\android\app\build.gradle file and add this line into the root dependencies section (around line 350)

    implementation("androidx.leanback:leanback:1.2.0-alpha01")

    '1.2.0-alpha01' is the current version as of August 2021, you can lookup the latest version here.

    6.

    Create banner.png image (320x180 px) and copy it to this folder:

    \platforms\android\app\src\main\res\drawable-xhdpi

    and possibly to

    \platforms\android\app\src\main\res\drawable-land-xhdpi

    7.

    Continue building the app with Cordova CLI:

    cordova build android ...

    Please refer to the official guide for more info, and let me know if you notice any mistake in my post.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)