android-resources

Assets folder in Android Studio Unit Test

那年仲夏 提交于 2019-11-27 20:20:37
问题 I have a Gradle project with the following structure: project/ src/ androidTest/ java/ main/ java/ res/ AndroidManifest.xml build.gradle Now I want to add a unit test which uses a resource (either "raw" or "asset"). I put my resource into project/androidTest/assets/test_file and access it with getContext().getResources().getAssets().open("test_file"); (in an AndroidTestCase ). However, this gives me a FileNotFoundException . How can I fix this? 回答1: It looks like you're trying to create an

Android Studio exports strings from support library to APK

无人久伴 提交于 2019-11-27 18:49:22
Recently i switched from Eclipse to Android Studio. I have a project with multiple module dependencies. One dependency is the support library appcompat, included like this: dependencies { compile "com.android.support:appcompat-v7:19+" } In the Android docs i found out that this library needs to be imported with resources, which seem to work OK. I use the library in my project without problems. The problem is, when i build an APK and run aapt, the outpus says: locales: '--_--' 'de' 'nl' 'pl' 'sl' 'fr' 'cs' 'es' 'it' 'ca' 'da' 'fa' 'ja' 'nb' 'af' 'bg' 'th' 'fi' 'hi' 'vi' 'sk' 'uk' 'el' 'tl' 'am'

Will a density qualified drawable folder or drawable-nodpi take precedence?

我与影子孤独终老i 提交于 2019-11-27 18:25:07
If I define drawables for a density qualified folder (eg drawable-hdpi), and also drawables to fall back on in drawable-nodpi , will a high density device use the -hdpi over the -nodpi ? What about if I take it a step further and also have the same setup for -land folders. I'm not sure what the precedence is for nodpi , but that should never be a problem. It sounds like you are misunderstanding the nodpi qualifier. You should not use nodpi as a fallback for assets that you don't provide at the device's density bucket. The correct fallback is a folder with no density qualifier (e.g. drawable/ )

Android - How to regenerate R class? [duplicate]

不羁的心 提交于 2019-11-27 17:56:08
Possible Duplicate: Developing for Android in Eclipse: R.java not generating I have imported a project into my Eclipse IDE, but it's giving me an error since R file is not generated automatically. How can I edit the R file so that it matches my project requirements? Goufalite In another stackoverflow question , somebody answered this : you must get rid of warnings and errors (syntax and links) in your xml files. This plus doing a clean / build project. Project -> Clean, and choose the option to build the project. I found this happening to me with a broken layout and everything blows up. Relax,

What Is The Difference Between -anydpi And -nodpi?

三世轮回 提交于 2019-11-27 17:07:26
If you use the Vector Asset wizard in Android Studio 1.5.0, any vector drawable XML you import using that wizard goes into res/drawable/ . However, the build/ directory, and the resulting APK show that those XML files get moved into a res/drawable-anydpi-v21/ resource directory. The -v21 part makes sense, as VectorDrawable is only supported on API Level 21+. However, -anydpi seems to be undocumented. I would have expected -nodpi , both for the original import destination and for where the build system elects to move it. Has anyone seen official statements for what -anydpi means, and what its

XML within an Android string resource?

落爺英雄遲暮 提交于 2019-11-27 17:06:13
问题 I was wondering if I could place XML within /res/values/strings.xml ? I ask this because I am checking for the XML data file for my application, if it does not exist yet then it creates it from the default contents that will be contained as a string resource. Eclipse tries to change the less than and greater than tags to their corresponding HTML entities when using the GUI to edit the strings. Is eclipse on the right track? Because I should think that it will be written out into my file as

Reading a resource sound file into a Byte array

被刻印的时光 ゝ 提交于 2019-11-27 16:45:59
问题 I have cheerapp.wav or cheerapp.mp3 or some other format. InputStream in = context.getResources().openRawResource(R.raw.cheerapp); BufferedInputStream bis = new BufferedInputStream(in, 8000); // Create a DataInputStream to read the audio data from the saved file DataInputStream dis = new DataInputStream(bis); byte[] music = null; music = new byte[??]; int i = 0; // Read the file into the "music" array while (dis.available() > 0) { // dis.read(music[i]); // This assignment does not reverse the

Ambiguous reference intellisense error from Resource.Designer.cs

别说谁变了你拦得住时间么 提交于 2019-11-27 14:34:44
问题 I am running into a peculiar bug when developing on Visual Studio 2017 that I have been able to ignore for a while, but is now beginning to really bug me. I refer to this issue as a bug rather than an error because I am still able to build my projects in Visual Studio and deploy them to my development device without errors or warnings from the build output. This might seem alright to ignore for a bit, but over time it has become an issue because my intellisense is underlining it in red as an

Sub folders in drawable resource folder? [duplicate]

こ雲淡風輕ζ 提交于 2019-11-27 14:26:31
This question already has an answer here: Can the Android drawable directory contain subdirectories? 20 answers How to access res/drawable/“folder” 5 answers I would like to create sub folders in drawable folder. I have a lot of file(such as png, xml) in drawable folder. I want to create sub folders in there to find the files easily. Can I create sub folders like that? Thanks. This is now (sort of) possible by using Android Studio and Gradle. Whilst subfolders are still not possible, it is possible to separate resources into different sets and have them merged by the build system . As an

Android layout error: “Resource id <res_id> is not of type STYLE (instead attr)”

淺唱寂寞╮ 提交于 2019-11-27 14:25:57
问题 I'm seeing an error I've never seen before w/ Android that's preventing some of my layout files from rendering in Eclipse. They render fine at runtime. The error that shows up in the graphical layout editor (and my Error log) is: "Resouce id 0x1010081 is not of type STYLE (instead attr)" I've searched for resource id 0x1010081 in my R files, and I can't find it so I'm guessing maybe somehow I have a conflict with a built in Android attr. I've also verified that all of my style attributes