0

I'm new to Android development, and I'm trying to manage projects from the command line using the SDK since I cannot get Android Studio 1.2 to work properly in my system (it's unresponsive).

The problem: I created a new project but the asset folder is missing.

Other SO answers (enter link description here) solve this by creating the folder from the IDE, or by pointing to the asset folder in the .iml file, with doesn't work in my case (I trying to mange the projects from the command line entirely)

There's also a solution editing build.gradle, but the project created from command line (using the SDK) doesn't seem to be a gradle project.

Any help would be appreciated.

Community
  • 1
  • 1
  • possible duplicate of [Where to place Assets folder in Android Studio](http://stackoverflow.com/questions/18302603/where-to-place-assets-folder-in-android-studio) – Anand Singh Jul 03 '15 at 18:58
  • If you are "trying to manage projects from the command line", what are you bothering with `.iml` files for? Those are for Android Studio or IntelliJ IDEA. Command line builds are via Gradle and the Gradle for Android plugin, and they do not use `.iml` files. – CommonsWare Jul 03 '15 at 18:58
  • Select the project view instead of the Android view in Android Studio and you'll be able to see the entire project and not only the Android related files. – Joaquin Iurchuk Jul 03 '15 at 19:00
  • @CommonsWare. Yes, you are correct. I was trying to explaing that other answers are aimed at the IDE, and I'm trying to do this from the command line. I rephrased the question. –  Jul 03 '15 at 19:23
  • @anand-singh That answer relates to the Android Studio IDE. I'm working from the command line using the Adroid SDK. –  Jul 03 '15 at 19:26

3 Answers3

5

Just create a directory called "assets" at the root of your project, i.e. in the same directory your AndroidManifest.xml lives. There's no need to "link that folder from the project". At least that's the case on my system, where I'm using Android SDK 24.4.1 (and I'm not using Gradle -- just emacs and ant).

Once I had assets/fonts/aisauc.ttf in there, the following code...

    import android.graphics.Typeface;
    ...

    Typeface greek =
       Typeface.createFromAsset(getAssets(), "fonts/aisauc.ttf");
    mytextfield.setTypeface(greek);

gave me a TextField with characters from the font I wanted.

0

How do I create the assets folder manually?

You make it the same you make any directory on your filesystem. Whether you use mkdir or a command-line equivalent, or whether you use your desktop OS's file manager, is up to you.

The default location for an assets/ directory is in a sourceset (e.g., src/main/assets/, to go along with src/main/AndroidManifest.xml and src/main/res/ and src/main/java/, where src/main/ is a sourceset). You can have an assets/ directory located elsewhere, if you choose, but then you will need to configure your build.gradle file to teach Gradle the alternative assets/ location for whatever sourceset you are trying to apply it to.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I know how to create a folder. What I don't is how to link that folder from the project. Configuring buid.gralde won't work, since the project created from the Android SDK doesn't seem to bet a gradle project. (gradlew, build.gradle, etc are missing). But I'll try and see if a can create a gradle project. Thanks. –  Jul 03 '15 at 19:43
  • @Joachim: "Configuring buid.gralde won't work, since the project created from the Android SDK doesn't seem to bet a gradle project" -- well, you need to build it somehow, and Google engineers have recommended everyone move away from Ant for ~16 months now. You're welcome to try to build it some other way, but Gradle and Gradle for Android are your most mainstream choice at the moment. – CommonsWare Jul 03 '15 at 20:03
0

In your left most sidebar or the sidebar that shows the app, manifests, java... etc, right click app > New > Folder (has the green android symbol next to it) > Assets Folder.

On the next screen leave the path as 'main' and click 'Finish'. Then you can drop whatever asset you want into the folder.

Will Buffington
  • 1,048
  • 11
  • 13