Android Studio: Inserting files into the Assets folder - android

I'm trying to copy and paste a whole bunch of files/folders into my Assets folder (that I created in the Main folder by selecting New > Folder > Assets Folder). But I get this error:
Cannot create class-file
The file in question is GUIDemo.class but there are others like it, too. Any suggestions how I can copy and paste the assets files into my project?

Android Studio uses Gradle-based build system, you should
putting assets/ inside of the source sets (e.g., src/main/assets/)
or create a folder under res
Try right click your app -- New -- Folder-- Assets folder
Change Android tag to Project, right click src --- make module app

Related

Android Studio - Copying image assets

How can I copy the following type of image asset so that I can use it in a different project? I was able to copy and paste a single png but not the whole set of images.
This project is a sample project from google codelabs.
Since the resources are in separate dpi folders, you need to copy the folders over, which is not possible in the "Android" view. If you click on the drop down, you should be able to get to a "Project Files" view where you can copy all the folders. Alternatively, you can use an external file explorer to copy the folders.
The easiest way is to navigate to where the project is stored. Once inside your application's folder, click app -> src -> main -> res -> drawable and select the images you wish to copy to another project. You can drag and drop these into your new android studio project or copy/paste them into the drawable folder in the new project's files as well.

assets folder missing in LibGDX project

I need to add some files to my android/assets folder of my project however, it isn't there ? I may have accidentally deleted it without knowing.
how do I create the assets folder?
Android studio doest provide ASSETS folder by default
you have to create it from
For the Android plugin, extra files and folders specific to Android:
AndroidManifest.xml
res/
assets/
aidl/
rs/
jni/
jniLibs/
Please read where to place asset folder

How can Copy and move `assets` folder data in runtime?

I have created 2 directories in the assets folder.
One is android and second is window.
--assets
1:- android
2:- window
I have a few files inside in the android folder. I need to copy all of them from the android folder to the window folder at runtime. How do I do it?
You can't. The assets folder is read-only and cannot be modified after compilation.
You can copy your files into a similar structure on the internal storage if you wish to do so.

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.

Android assets folder not added to apk

I'm pretty new to eclipse and Android and I'm trying to add some files to the assets folder, but certain files and directories are not being included in the .apk file.
I have set-up the following structure in the solution:
/assets
/textures
/test.png
/splash.png
/xml
/testData.xml
I don't know if there is a specific way to get eclipse to re-build/compile the project and add the new assets to the assets folder in the .apk, but the /xml subfolder (and its contents) are not in the apk. Subsequently I get FilenotFoundExceptions thrown when I deploy the app. The textures are all included.
How can I force a recompile and rebuild of the apk and is there anywhere to manually check which files are included in the project (like an assets manifest file)?
As far as I know there are no restrictions placed on hierarchy or file formats for within the assets folder. Also, when I dragged the files from the desktop to the solution explorer, I selected 'copy files to project'.
Thanks
It appears one cannot use upper-case letters in the naming of files within the assets folder. Contrary to my example above, I was actually using camel-backed file names within the folders. After changing the file names to lower-case, the apk was automatically re-built with the assets the next time I deployed

Categories

Resources