How to tell Eclipse that folder was moved - android

I have moved (the content of) the src folder of my Android project to src/main/java because I want to use gradle. So far no problem.
But then I moved the res folder to src/main/res because I want to use a different res folder in src/debug/res for my debug builds. Now Eclipse gives me that error:
ERROR: resource directory '/.../MyProject/res' does not exist
How can I tell Eclipse that the folder was moved? I already moved the folder back and then again to the new location using right-click -> Refactor -> Move. So Eclipse should know where the res folder is.

Related

Assets Folder Not Getting Added To Android Studio Project and APK

I'm trying to add an Assets folder to my Android Project in Android Studio 2.1.2. I right click on the project and choose New -> Folder -> Assets Folder. In the project pane on the left, it doesn't show up when Android is selected. If I switch to Project Files, it does appear, however it looks like a normal directory, rather than looking like a resource directory. I then tried adding files to it (jpgs), both through Android Studio and through the file explorer (all file names are lowercase with no special characters). If you unzip the apk that gets created though, it doesn't contain an Assets directory or the added files. Also sometimes the assets directory will disappear from the project files pane, although it's still in explorer.
What step am I missing to get to the Assets directory properly added to my project?
Note: this is for a LibGdx project that expects image files to be there.
Finally got it. Appears to be a bug in Android Studio, but to make it work, in the Project pane, go to Android view and (this next part is critical) right click on the res folder and go to New->Folder->Assets folder. You might want to click change folder location to be sure it's going into the main folder (mine was) just to be on the safe side.
You must right click on the res folder. That was my issue. If you right click on the module or anywhere else, even though the folder will get created in the proper spot, Android Studio and gradle won't treat it as a resource directory and just ignores it.
Be sure to create folder in app/src/main/ and call it assets.
For me in Android Studio 3.6.2, the assets folder wasn't showing up in the "Android" view, no matter where I tried to create it, after trying the other suggestions here. In the "Project" view it showed up in app/assets as a plain folder. I then drag-and-dropped it to src/main/assets and it automatically changed its icon to the same icon as the res folder, and after this it is now also showing up in the "Android" view, so I guess Android Studio is picking it up correctly now, and it appears to be a bug in Android Studio.
If you created a folder in your res directory and named it "assets" and now as "Nullqwerty" mentioned you could not able to solve your problem and you face to the duplication error, just go to the project tab (or press Alt + 1) and in the view mode, change it from "Android" to "Project", then expand all folders in your project to find assets folder in your src\main\res directory (or in src\main path) and right-click on your "assets" folder (if you created it before by adding a "Directory" and named it assets), then change your view mode from "Project" to "Android", again, and right-click on "res" directory->New->Folder->Assets Folder. Then click on "Finish" button to see the assets folder on your main directory as you want. That's it ;)

Adding an assets folder in Android Studio

Android Studio has changed its project structure yet again... now it is
project
└── app-module
├── manifests
├── res
└── java
I've been looking everywhere online, but I can't find where to put the assets folder. When I try to create the folder via the directory viewer in Android Studio (right-click, New... directory) the "directory" option is not available. The only available options are:
Java Class
File
Module
Package
Image Asset
None of which will do what I want here.
Has anyone figured this out?
An image of how to in Android Studio 1.5.1.
Within the "Android" project (see the drop-down in the topleft of my image), Right-click on the app...
You can click on the Project window, press Alt-Insert, and select Folder->Assets Folder. Android Studio will add it automatically to the correct location.
You are most likely looking at your Project with the new(ish) "Android View". Note that this is a view and not the actual folder structure on disk (which hasn't changed since the introduction of Gradle as the new build tool). You can switch to the old "Project View" by clicking on the word "Android" at the top of the Project window and selecting "Project".
According to new Gradle based build system. We have to put assets under main folder.
Or simply right click on your project and create it like
File > New > folder > assets Folder
To specify any additional asset folder I've used this with my Gradle. This adds moreAssets, a folder in the project root, to the assets.
android {
sourceSets {
main.assets.srcDirs += '../moreAssets'
}
}
right click on app-->select
New-->Select Folder-->then click on Assets Folder

Eclipse cannot recognize the linked 'res' folder for an android project

I tried to reuse the "drawable" folder of the first android project. For the second project "drawable" file, I just created a linked folder to "res" of my first project and expected any change on the "drawable" of first project would reflected on the second one. But the system does not recognize the virtual folder, how can I fix it without copying and pasting?
Error appears on the lines like: android:background="#drawable/button_deepskyblue"

Android ant override location of res folder using build.properties

So I am setting up my project to use ant to do automated builds but with one of the external libaries I have run into an issue. The external libary src and res folder point to another projects res and src folder (using LinkedResources in eclipse to do this). So the build fails when building this project because it cannot find the res folder. I made it find the src folder by overriding the source.dir in ant.properties to point to the path of the src folder. I tried to the same by using resource.dir but it does not work. Is there any way to do this ?
You can change the res location using the property resource.absolute.dir. The default value is res.

assets/ directory not being packaged into .apk from eclipse

I have the following directory structure in an app I'm porting to Android (ndk).
Project
/src/ -- Location of my .java
/jni/ -- Location of my Android.mk and Application.mk
/assets/ -- Location where I put my raw data resources
/code/ -- Location of actual c++ src code
The original structure had a "res" directory instead of "assets", but these were just my raw resources, didn't adhere to the android packaging/naming structure, so resulted in errors.
The problem is when I renamed it "assets" the errors in eclipse went away, but the assets were not included in the bin/Project.apk file. When I do aapt l Project.apk, sure enough there is no "assets" items and the apk size is far too small anyway.
So I'm sure I missed a step after renaming the "assets" dir, where I tell eclipse to package these files, but I have no idea what it was. Help appreciated!
I'm using the same structure for one of my apps in Eclipse, with no special references in the manifest. Have you tried a full sweep refresh?
Right-click on the project, select "Refresh"
Select "Project" menu, then "Clean..."
Restart Eclipse
I've occasionally had projects of varying language in Eclipse which required all of the above 3 steps in order to fully update the project files, specifically when I made such changes as renaming folders or added completely new files.

Categories

Resources