Can't import assets from adobe XD into android studio - android

I made a UI layout using adobe XD and wanted to export it to use in android studio.
I achieved this by using the Export-kit plugin, which conveniently exported all my required assets for one page into a folder.
Exported assets folder
the readme.txt then directs me to copy all these assets to the folder for the noactivity project folder for android studio.
after doing so , I still don't get any response.
So, I try it with a basic activity and manually add all the required XML codes (activity_main,colours,styles,e.t.c) , but still don't see anything.
I know that the skins exported from xd are in the project folder
(Copied values in the projects folder)
but I cant seem to view them on android studio.
Android Studio Window
any help in this issue will be really appreciated.

You have to put those files in the drawables folder inside the res folder, and keep the colors, string into their respective folder in the values folder inside res.

Related

Android Studio newly created folders not showing

I am using Android Studio 2.1.1 (currently the most updated stable version).
I created new directory inside 'res' by name "values-21"
and it don't shows up.
But if I go to the physical location of 'res' on the hard drive I can see that its exist.
and of course I checked using both Android and Project Files structure but either way its not showing it.
I wanted to check where is the problem so I created another directory by name "menu", and the last one was shown.
just to be sure I tried to create the same directory again ("values-21") but Android studio didn't allowed it because this directory allready exist's.
any ideas how to fix it?
Update - the solution is to create new directory using the "Android resource Directory" option and not by "Directory" option.
all you values xml files stored in values, values-21, values-mdpi or other physical folder in AndroidStudio displayed in one res/values folder.
It will not show until you copy a XML file into values-21, android studio consider all values folders to be of same family and it shows only one folder and the files with post script of the family in which it lies.
copy some layout file from resource directory and through windows explorer paste in that the folder that you have created i.e values-21 and now come back to android studio and check the folder should be there.
Happy coding

Reading txt, mp3 and other files from Android Studio

Recently I installed Android Studio, before I used Eclipse. While using Eclipse I could put all the files in Assets directory and access it using getassets method. For example:
InputStream ims = getAssets().open("textnew.txt");
Can you please advise:
Where to store files in Android Studio? Should I create folders in /res directory myself and put files there. For example: res/raw/textnew.txt
How to access those files? For example I need to open txt file in order to place its content to TextView. How to do it?
Thanks!
You can still use an asset folder in Android Studio.
Create manually a folder asset in your app directory.
Using the menus : File / New / Folder / Assets Folder
I think that the only difference with Eclispe is that in Android Studio the folder is not created by default.
Android Studio has a nice assistant to create an asset-folder. This way it will be created in the correct location.
Right Click on your project
Click "New" -> "Folder" -> "Assets-Folder"
Follow the assistant
Your folder should be created and will be added to your main-sourceset.

Font file not loading on Libgdx Android

I am using the following code to load font in my libgdx project.
BitmapFont(Gdx.files.local("fonts/test.fnt"))
This is working fine when i launch using Desktop Launcher.
however when I launch using Android Launcher i get the following error.
com.badlogic.gdx.utils.GdxRuntimeException: File not found: fonts/test.fnt (Local)
I am not sure What am i doing wrong here. My Android project's assets for folder contains fonts folder and has the files test.fnt and test.png.
On Android, assets can only be accessed using the internal file system:
Gdx.files.internal("filename");
Are you using different assets folders for both desktop and android so that you have separate copies of your files? Or are you using the same assets folder for both desktop and android?
If your are using the same assets folder, then both desktop and android have to use the android assets folder. Android is finicky in this way. So you will have to set your desktop assets folder to point to the android assets folder, then anytime you add new assets you have to add them to the android folder.
This is how I initialize my fonts.
fontTexture = new Texture(Gdx.files.internal("assets/texture/font.tga"));
buttonFont = new BitmapFont(Gdx.files.internal("assets/texture/font.fnt"), new TextureRegion(fontTexture), true);
By using internal it searches your project for the folder containing the assets for me that folder is "assets" my project looks something like this:
Eventhough I clearly have my assets packed into my project, I will get the same error when I export my application just like this.
Now here's how to solve that issue. You need to open up your exported project with something like 7z or Winrar, and manually drop in the 'assets' folder. In your case "fonts". This should should fix it, atleast I always have to do that, it never packs the assets for me.

Android - How do I create the assets folder manually?

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.
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.
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.
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.

Can't find my assets folder

I'm developing an Android application and I want to add a custom font. I read about the epic assets folder and her location over some themes like this. I check my src folder - it's not there. I check almost every single directory from my project tree and I still can't find her. Here is the picture of my directory tree.
And by the way, on my previous project, on Android 0.6 I used to add a custom font but I don't remember where was the folder located and now, on Android Studio 0.8 I even can't find my folder.
Under your main folder you need to make an assets directory.
Right click on the "main" folder -> New -> Directory
And then name it "assets" and here is what it should now look like (minus the xml file of course)
Todays IDEs do most of the work for you. But if they fail, why you not just try to do it yourself? Place your assets-folder in src\main\assets and you should be fine.

Categories

Resources