Tag Archives: module

[Solved] Android Studio Error: The binary version of its metadata is 1.5.1, expected version is 1.1.15.

Question:

Android studio reports an error: module was compiled with an incompatible version of kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
Solution 1:

Add ext.kotlin in build.gradle of the project_ Version = "1.3.72" (lower version) changed to ext.kotlin_ Version = "1.5.21" (not necessarily 1.5.21, but also the latest version). Just sync and run again

Solution 2:

Open build.gradle under your module (my module name here is MyLibrary) directory, delete some lines in dependencies, and only the corresponding lines in the second figure are left. Just run it again

these lines remain:

[Solved] TS Error: Could not find a declaration file for module

Some NPM packages have no problem using native JS, and some packages will report “could not find a declaration file for module” error after changing ts.

There are two ways to solve this problem

1. Download the @ type/error reporting package (some package developers may not upload their own. D.ts code to the NPM branch, then they will report an error saying that they can’t find this package, don’t worry about the next step)

2. The most direct, simple and effective solution: create a new shims-vue.d.ts file in the root directory of the project

//declare declaration declares an ambient module (i.e., a module declaration without internal implementation) 
declare module '*.vue' {
  import Vue from 'vue'
  export default Vue
}
 
 
declare module 'XX'
// xx is the name of the package that your package cannot find declared

The only thing to note is that after the first creation of the file with vscode, it should be restarted to see the effect, and then it will take effect. After the declaration is saved, the error will disappear immediately.

0xc0000005: an access conflict occurred while reading location 0x00000020

0x in.exe… Unhandled exception at: 0xC0000005: Access conflict occurred while reading position 0x00000020

Error: : PostMessage (AfxGetMainWnd () – & gt; M_hWnd, UM_XX, 0, 0);

or: : sendMessage (
AfxGetMainWnd()-> M_hWnd, UM_XX, 0, 0);

How to solve it?
Verify that afxGetMainWnd () returns NULL

int k = (int)(& (((CWnd*)NULL)-> m_hWnd));
The value of k is 0x20

In general: afXGetApp ()-> GetMainWnd (); AfxGetMainWnd() is used only on the main thread;

How: foreground thread and background thread, afxGetApp ->; GetMainWnd() differs from AFXGetMainWnd ()

AFXGetMainWnd () is an example of a window handle that can be used to retrieve a window handle. AFXGetMainWnd () is an example of a window handle that can be used to retrieve a window handle. Clever you must have already understand, if you have been tracking AfxGetMainWnd () call, will find that it earned a AFX_MODULE_THREAD_STATE threading module save active threads in the window handle, and a background thread since no window, then obtains the window handle is you from??(maybe someone’s understanding of the background is not display window, even with all the window, as long as it doesn’t show is a background thread, strictly speaking is not the case, the window is mainly used to interact with the user, a window is hard to avoid jam, And the background thread is often used to carry out some behind the operation or processing, is through the foreground information or data to carry out the corresponding operation, if the window is hidden to talk about what information transfer?The case can not be done in the background like other threads. The key is to know the difference and how to use it.)
AfxGetApp()-> GetMainWnd () is the main window handle, no matter in that thread calls are no problem, because it is first obtained the main thread handle, to achieve the main thread of the active window (such as switch view can lead to replacement, I am not sure this kind of circumstance), if there is no active window is the main window, any program must have a main window, so it calls there is no problem, if you want to achieve the program’s main window suggested AfxGetApp () – & gt; GetMainWnd().
Note that the console program has no window and its window handle is always 0. Second, the background thread is actually a desktop control program, just not the main thread. Also, threads created using functions such as API CreateThread cannot generate CWinThread objects. So if you want to use CWinThread object function, and some of the global function, as AfxGetMainWnd (), you must use CWinThread object CreateThread function, or use the AfxBeginThread () function creates a thread, or may be an error, because the MFC to the management of the thread is done through the CWinThread object, it is not hard to see through the tracking code below you. I remember that there was a predecessor once mentioned this problem, but I do not know whether it understands the reason
Here is the trace code:
_AFXWIN_INLINE CWnd* AFXAPI AfxGetMainWnd()
{ CWinThread* pThread = AfxGetThread();
return pThread! = NULL ?pThread-> GetMainWnd() : NULL; }

CWinThread* AFXAPI AfxGetThread()
{
// check for current thread in module thread state
AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
CWinThread* pThread = pState-> m_pCurrentWinThread;
// if no CwinThread for the module, then use the global app
if (pThread == NULL)
hread = afxGetApp ();
return pThread;
}
You can see that calling afxgetMainwnd () on the main thread is not a problem (except for console programs) because it returns the main thread handle if the fetched thread handle is empty.
_AFXWIN_INLINE CWinApp* AFXAPI AfxGetApp()
{ return afxCurrentWinApp; }

CWnd* CWinThread::GetMainWnd()
{
if (m_pActiveWnd ! = NULL)
return m_pActiveWnd;// probably – place in active
// when not inplace active, just return main window
if (m_pMainWnd ! = NULL)
return m_pMainWnd;
return CWnd::GetActiveWindow();
}
I don’t need to worry about AFXCurrentInApp.
Hey hey, all finished, if your program exists similar to the above problems can be sure to change back oh.

Python: Understanding__ str__

The following is my understanding if there is anything wrong with me. Please do tell me. Thank you very much!
In The Python language, successie __str__ is usually formatted this way.
class A:

def __str__(self):

return “this is in str”

Literally, ___ is called by the print function, usually return something. This thing should be in the form of a string. If you don’t want to use the STR () function. If you print a class, print first calls each ___ by str__, such as STR. Py

#!/usr/bin/env python
                                                                                                                                                                                 
class strtest:
    def __init__(self):
        print "init: this is only test"
    def __str__(self):
        return "str: this is only test"

if __name__ == "__main__":
    st=strtest()
    print st

$./str.pyinit: this is only test

str: this is only test
As you can see from the above example, the function with ___ is called when you print an instance of STRtest st.
By default, the python objects almost always have the __str__ function used by print. S the dictionary with ___, see the red part:
> > > dir({})
[‘__class__’, ‘__cmp__’, ‘__contains__’, ‘__delattr__’, ‘__delitem__’, ‘__doc__’, ‘__eq__’, ‘__format__’, ‘__ge__’, ‘__getattribute__’, ‘__getitem__’, ‘__gt__’, ‘__hash__’, ‘__init__’, ‘__iter__’, ‘__le__’, ‘__len__’, ‘__lt__’, ‘__ne__’, ‘__new__’, ‘__reduce__’, ‘__reduce_ex__’, ‘__repr__’, ‘__setattr__’, ‘__setitem__’, ‘__sizeof__’, ‘__str__’, ‘__subclasshook__’, ‘clear’, ‘copy’, ‘fromkeys’, ‘get’, ‘has_key’, ‘items’, ‘iteritems’, ‘iterkeys’, ‘itervalues’, ‘keys’, ‘pop’, ‘popitem’, ‘setdefault’, ‘update’, ‘values’]
> > > t={}
> > > t[‘1’] = “hello”
> > > t[‘2’] = “world”

> > > t
# is equal to print t

{‘1’: ‘hello’, ‘2’: ‘world’}

> > > t.__str__()

“{‘1’: ‘hello’, ‘2’: ‘world’}”

You can see a dictionary, print t and t. str__() are the same. Simply output the contents of the dictionary as a string.
If it’s not a string returned in the function ___, see str1.py

#!/us/bin/env/python                                                                                                                                                                                        
#__metaclass__ = type
#if __name__ == "__main__":
class strtest:
    def __init__(self):
        self.val = 1
    def __str__(self):
        return self.val

if __name__ == "__main__":
    st=strtest()
    print st

$./str1.py

Traceback (most recent call last):
File “./ STR. Py “, line 12, in < module>
print st
TypeError: ___, returned non-string (type int)
Error message with: ___ returned a non-string. Here’s what we should do: see str2. Py

#!/usr/bin/env python                                                                                                                                                                                        
#__metaclass__ = type
#if __name__ == "__main__":
class strtest:
    def __init__(self):
        self.val = 1
    def __str__(self):
        return str(self.val)

if __name__ == "__main__":
    st=strtest()
    print st

$./str2.py

1
We used STR () to change the integer to a character.

(EE) Failed to load module “fbdev” (module does not exist, 0)

Enter the command startx in the virtual machine:
The following error occurs.
(EE) Failure to load module “Video Electronics Standards Association” (module does not exist, 0)
(EE) failed to load module “fbdev” (module does not exist, 0)
(EE) failed to load module “evdev” (module does not exist, 0)
(EE)No driver matching evdev input
(EE) failed to load module “evdev” (module does not exist, 0)
(EE)No driver matching evdev input
(EE) failed to load module “evdev” (module does not exist, 0)
(EE) No input driver matches “evdev”Solution.
yum install xorg-x11-drivers

Error: /usr/bin/python: Error while finding module specification for ‘virtualenvwrapper.hook_loader’

reasons: workon command fails, the Python version changes, is to use the previous python3.6 install Python virtual environment, relevant documents is in the/Library/Frameworks/Python framework Versions/3.6/bin
solution 1: to install a virtual environment in new python3.7 environment

$sudo pip3 install virtualenv virtualenvwrapper
$source .bashrc

the solution 2: will/Library/Frameworks/Python framework Versions/3.6/bin three files in the directory, copy it to/usr/local/bin directory in

$cd /Library/Frameworks/Python.framework/Versions/3.6/bin
$cp virtualenv-clone virtualenvwrapper.sh virtualenvwrapper_lazy.sh /usr/local/bin

Error: unable to resolve dependency for… Could not resolve project

changed some things of the project two days ago. After submitting, I found that the compiler always reported errors, but the packaging was ok. Error message is as follows:

ERROR: Unable to resolve the dependency for ‘: XXX @ debugProduction/compileClasspath’ : Could not resolve project: yyy.
Show Details
Affected Modules: XXX

where ‘XXX’ and ‘yyy’ are the two modules in my project. I looked for many ways on the Internet, but I couldn’t solve them.
later went back to the last change and found that I had changed build.gradle for module x, but not for module y, and the configuration of buildTypes for the two modules was inconsistent.

so the obvious solution is to copy the configuration of buildTypes in build.gradle of module x into build.gradle of module y.

does not have to be copied exactly, only has to be configured in the same format as the two modules . My error was caused by the buildTypes in Module X, which added the configuration of the releaseTest mode, but not in Module Y.