cannot find the declaration of element 'resources' - resources

Cannot find the declaration of element
This is in values.xml (a system therefore uneditable file) and is giving me
Cannot find the declaration of element 'resources'
This is an error that is preventing my project from building

It would really help if you could post a log of the actual error, it should tell you which file and line is causing the issue, and why.
Resources need to be pointed to in order for your project to compile properly and with the correct resources. For example, when coding with java (referring to building for Android) you might see an import of a resource directory.
This could look like:
import com.android.systemui.R;
or
import com.android.settings.R;
The R you see there represents a resource directory.
Posting your build error along with the file(s) you modified would be very helpful.

Related

Unable to set environment variable for ctypes (c library for python)

I need some third-party c library to be imported into a low-level module. I'm following these instructions. It says that find_library() should help me find such a lib, excluding any lib prefix and .so suffix.
#next 2 lines just to test
test =find_library('spcm_linux')
print(test)
#this line below is the actual code
spcmDll = cdll.LoadLibrary("libspcm_linux.so")
Returns:
None
OSError: spcm_linux.so: cannot open shared object file: No such file or directory
My library lives at:
/usr/lib/gcc/x86_64-linux-gnu/libspcm_linux.so
Reading about find_library() from the docs, it tells me that I can set an environment variable to add an environement variable (LD_LIBRARY_PATH). So in /etc/environement I have:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:"
PYTHONPATH="/home/fv/.local/lib/python3.6/site-packages"
LD_LIBRARY_PATH="/usr/lib/gcc/x86_64-linux-gnu"
I restart, try and it still doesn't work (same error message).
Any other way to "find" my library? Could put it in my program.py directory directly & import it some other way?
EDIT:
However, it does find libgomp.so.1, which is in the exact same folder as the library I'm trying to load. If that helps...
Turns out the root of the issue was rights.
Rights to the libspcm_linux.so lib weren't set properly and thus the script had no access rights to it.
However, the error that popped up was still about No such file or directory. I presume this is because it's a C library, which ctypes tried to load. It couldn't load it (because it didn't have the rights to it) however apparently it didn't see it fit to propagate the error (or couldn't because of some technicalities of how C code is loaded, perhaps).
Therefore from it's point of view, it couldn't load the requested library, and told me so - "No such file or..." even if this hide the real cause of the problem.

Why Is Doppl Trying To Pull in ReactiveStreams?

I am attempting to convert parts of an Android app to iOS using Doppl, and I am getting a strange result: Doppl keeps trying to pull in android.arch.lifecycle:reactivestreams, even though I don't want it to.
Specifically, in app/build/j2objcSrcGenMain/android/arch/lifecycle/, there is a reactivestrams/ subdirectory with R.h and R.m files in it. This seems to make Xcode cranky and may explain why I had some oddities with pod install.
My app/build.gradle has compile "android.arch.lifecycle:reactivestreams:$archVer", because my activity is using LiveDataReactiveStreams.fromPublisher(). However:
The activity is not in the translatePattern (and since its code is not showing up in app/build/j2objcSrcGenMain/, I have to assume that the translatePattern is fine)
I do not have a doppl statement related to reactivestreams, because there does not appear to be a Doppl conversion of this library (nor should it be needed here)
AFAIK, nowhere else in this app am I referring to LiveDataReactiveStreams, which AFAIK is the one-and-only public class from the reactivestreams library
So, the questions:
What determines whether Doppl creates R.h and R.m files for some dependency? It's not the existence of a doppl statement, as I have doppl statements for a lot of other dependencies (RxJava, RxAndroid, Retrofit) and those do not get R.h and R.m files. It's not whether the dependency is referenced from generated code, as my repository definitely uses RxJava and Retrofit, yet there are no R files for those.
How can I figure out why Doppl generates R.h and R.m for reactivestreams?
Once I get this cleared up... do I re-run pod install, or is there some other pod command to refresh an existing pod with a new implementation?
Look into 'app/build/generated/source/r/debug' and confirm there's an R.java being created for the architecture component. It'll be under 'android/arch/lifecycle/reactivestrams'.
I think there are 2 problems here.
Problem 1
Somehow Doppl/J2objc is of the opinion that this file should be transpiled. It could be either that 'translatePattern' matches with it, or that something in the shared code is referencing it. If you can't figure out which, please post a comment and I'll try to help (or post in slack group).
Problem 2
Regardless of why that 'R.java' is being sucked into the translate step, because of how stock J2objc is configured, the code is being generated with package folders instead of creating One Big Name. That generated file should be called 'AndroidArchLifecycleReactivestramsR.h' (and AndroidArchLifecycleReactivestramsR.m). Xcode really doesn't like package folders. That's why there's a slightly custom J2ojbc being used with Doppl, so we can have files with big names instead of folders.
In cases where you intentionally use package names that match with what J2objc considers to be "system" classes, you need to provide a header mapping file to force long names. The 'androidbase' doppl library needs to add a lot of files that are in the 'android' package, which J2objc considers "system". We override those names in the mapping file.
build.gradle
https://github.com/doppllib/core-doppl/blob/master/androidbase/build.gradle#L19
mapping file
https://github.com/doppllib/core-doppl/blob/master/androidbase/src/main/java/androidbase.mappings
I screwed up.
In my dopplConfig, I have:
translatePattern {
include '**/api/**'
include '**/arch/**'
include '**/RepositoryTest.java'
}
In this case, **/arch/** not only matches my arch package, but also the arch package from the Architecture Components.
Ordinarily, this would not matter, because the Architecture Components source code is not in my project. But, R.java gets generated, due to resources, and the translatePattern includes generated source code in addition to lovingly hand-crafted source code. So, that's where my extraneous Objective-C was coming from.
Many thanks to Kevin Galligan for his assistance with this, out on the #newbiehelp Doppl Slack channel!

I am unable to access imported models attribute

import pocketsphinx
for phrase in pocketsphinx.LiveSpeech():print(phrase)
So the weirdest thing ever happened. This code worked fine. Then I cut and pasted it into another python file in the same project and boom I get, AttributeError: module 'pocketsphinx' has no attribute 'LiveSpeech'. pocketsphinx is in my external libraries and my ide recognizes it, but now there is no autocomplete options with pocketsphinx.(should have recommendations). So this is weird. When I cut and past back to old file it does not work either now. ??? Hmm... Why
This kind of error often happens when there is a module in the project directory with the same name as the one being imported. This file is then found earlier when traversing sys.path, so it shadows the library you're trying to import.
So in this case you probably have a file pocketsphinx.py within your project directory. If you rename that to something else then it should work.

module name and Path in haskell

I have
root/Main.hs :
import ADT.Stack
main :: IO ()
main =
putStrLn "Hi"
root/ADT/Stack.hs
module Stack (Stack, empty, isEmpty, push, top, pop) where
...
Upon loading Main.hs, I have the error
File name does not match module name: …
Saw: ‘Stack’
Expected: ‘ADT.Stack’
If I change the module name to ADT.Stack in Stack.hs, I can get rid of the error.
However, I dont understand the reason behind such constraint.
Is there no way to avoid specifying in the code of Stack.hs what is already encoded in the name of the directory in which it is contained ?
If there are no alternative way, is there any good reason this ?
If you're using the hierarchical namespaces, your module names should reflect the full path. So, in root/ADT/Stack.hs, you should have
module ADT.Stack (Stack, empty, isEmpty, push, top, pop) where
After that, as you have observed, everything should be fine.
I am not aware of any possibility to derive the module name not only from the name you give it in the file, but also on the location of the file. (That is what you are after, aren't you?) Of course, this should be possible with some fancy preprocessing, but you probably don't want to go there.
So, then, why are things like they are? Not sure whether, for you, it qualifies as a good reason, but one can argue that this scheme has as an advantage that by simply moving a file to another directory you don't silently break any client codes. Instead, you get an error already when compiling the moved file.
The redundancy in the file location and the module name allows processors to find imported modules with only a minimal set of "search paths". Also, it provides a standard for organising source files over larger projects.

How to get XHP working in hack/hhvm on Ubuntu

I've installed hack-nightly and set up fastcgi using nginx by following the instructions on the website, however I'm getting an error when trying to create a simple file that uses xhp:
<?hh
$x = <html><body>hello</body></html>;
echo $x->toString();
Error:
Fatal error: Class undefined: xhp_html in /
Is there a step I need to take to enable this, or an additional import or package to install?
You need to include the XHP library, which you can find here. This defines the :xhp base class as well as all the HTML classes. Put all three files somewhere in your source tree then include init.php before doing anything with XHP.
There's currently a discussion going on in the HHVM.dev group on Facebook about if the library should be included by default or not, which you can view at https://www.facebook.com/groups/hhvm.dev/229787297210377/.

Resources