android data binding: how to get useful error messages - android

In android studio 2.1, the compile time error messages from xml mistakes are entirely non-helpful:
Error:(11, 41) error: package mypackage.databinding does not exist
Error:(15, 13) error: cannot find symbol class MyActivityBinding
The real error would usually be something like "there's no such attribute android:adapter", or "variable foo doesn't contain property bar" or something like that. But instead of actually showing such errors, it shows the above unhelpful ones, which only tell you that the bindings weren't generated because of some unknown error.

The way I use in Android Studio 4.0:
Select the top level Build: failed item on the Build Output panel
On the right part click Run with --stacktrace. When build is finished select the top Build: failed item again on the left panel. You'll get a databinding error description on the right panel:
In my case it's:
[databinding] {"msg":"Cannot find a getter for \u003ccom.google.android.material.slider.Slider app:value\u003e that accepts parameter type \u0027java.lang.Float\u0027\n\nIf a binding adapter provides the getter, check that the adapter is annotated correctly and that the parameter type matches.","file":"SliderDatabinding\src\main\res\layout\activity_main.xml","pos":[{"line0":14,"col0":8,"line1":21,"col1":41}]}

Clink on Toogle View, under the 'Build' icon will give you details logs

There's no easy way for now. In general, if you face such compilation error and error messages point at missing databinding classes it is usually either bad reference from layout (i.e. you try to access members classes you assigned do not expose - usually happens when you c&p layouts).
Even worse, when you use other code generating libraries (Icepick, Butterknife, etc) then the real culprit can be often in code completely unrelated to binding. So when something like this occur in my code, I usually check Gradle Console view and read it from the end up, ignoring all error messages related to databinding like "missing class" or "package does not exists"

One way of getting the proper error is to run gradle in a terminal with '--info', like:
gradle :app:build --info
That's not exactly integrated into AS, so I can't really accept that answer.

Related

Unordered_map declaration throws error with NDK (clang), works fine with gcc

I'm trying to run a C++ project on Android. The following statement appears in one of the source files (part of a big project).
std::unordered_map <int, std::shared_ptr<Frame>, std::hash<int>, std::equal_to<int>,
Eigen::aligned_allocator< std::pair<const int, std::shared_ptr<Frame> > > > idToKeyFrame;
The NDK build complains the following
sysroot/usr/include/c++/v1/unordered_map:1684:5: error: static_assert failed due to requirement 'is_same<value_type, typename allocator_type::value_type>::value' "Invalid allocator::value_type"
I cannot spot what part of declaration is incompatible. Please help in fixing this error.
cplusplus.com reference
Update
When I modify the allocator (as suggested in comment by Marc) to Eigen::aligned_allocator<std::pair<int, std::shared_ptr<Frame>>> The error message remains the same but line number changes
sysroot/usr/include/c++/v1/unordered_map:854:5: error: static_assert failed due to requirement 'is_same<value_type, typename allocator_type::value_type>::value' "Invalid allocator::value_type"
Update++
According to this answer :
libstdc++ does not static_assert, libstdc++ ignores the exact type of the allocator and rebinds it to the container's value type.
and
Clang/libc++ are not forgiving
Yet another Update
I have been able to go past the error by commenting out the line in the source for unordered_map. This is a resort for now (until I get a solution).

Android Studio C++ inline compiler doesn't understand smart pointer upcasting

My Android Studio inline compiler shows me an error when passing an unique_ptr of a derived class to a function expecting an unique_ptr of a parent class. But the code compiles as I was expecting.
The error message from the code snippet above:
Parameter type mismatch: Class 'std::unique_ptr<B>' is not compatible with class 'std::unique_ptr<A>'
I guess is this a bug, related to Android Studio ? I was wondering if there was an options for this error checker, couldn't find anything
EDIT: Note that this code compiles with no errors from the compiler (the error I quoted is from the Android Studio's real time error checker). You can check the code here: https://ideone.com/xlUsKs

Error building openframeworks for android: “ invalid use of incomplete type ‘class Poco::Path’”

I am trying to build an android application with OF. The application runs in two other computers. However, it does not work on mine. I am using a mac.
I run the command "make AndroidDebug" in the project folder, and this is the error I have:
/Library/openFrameworks/addons/ofxHTTP/libs/ofxHTTP/src/PostRouteFileHandler.cpp:98:46: error: invalid use of incomplete type 'class Poco::Path'
ss << Poco::Path(formFileName).getExtension();
I have installed poco, but nothing changes afterwards.
What can I do to solve this?
Thanks
Have you included Poco/Path.h?
A forward declaration might appeared earlier (possibly in another header) without complete definition.

Printing by monodroid

I have a BIXOLON mobile printer, I can print by this device in windows mobile programs.
I want to print by this device in MONODOIRD applicaiton...
there is sdk, but the lib that use that sdk is java...
is any body know how can I print by this device in monodroid?!
Is your "lib" is a .jar file? If it is, bind it, which will make it accessible from C#.
after I read xamarin help about bindding jar file, I get some errors....
I listed in the end of this post...
I need this jar file compile completly...
Warning 1 missing class error was raised while reflecting com.bixolon.android.library.BxlService : android/hardware/usb/UsbManager
Warning 2 missing class error was raised while reflecting
com.bixolon.android.library.UsbLauncher : android/hardware/usb/UsbManager
Warning 3 For ConnectThread, could not find enclosing type 'BxlService'.
Warning 4 For ConnectThread, could not find enclosing type 'BxlService'.
Warning 5 For ConnectedThread, could not find enclosing type 'BxlService'.
Warning 6 For ConnectedThread, could not find enclosing type 'BxlService'.

XMLVM Android to iPhone Errors

The conversion of my Android application to the iPhone ObjectX environment as described in the XMLVM user manual works almost fine on my MAC, but I end up with 3 errors in the resulting XCode:
The first two errors simply relate to missing files, namely:
org_w3c_dom_Node.h
android_app_DatePickerDialog_OnDateSetListener.h
These are clearly not files from the converted Android application. Where can I get these from?
The third is an error that keeps coming up in the file
java_lang_String.h
The error message is:
typedef NSMutableString java_lang_String: redefinition as different kind of symbol
This error has been reported before in the XMLVM user group but as far as I know has never been answered sufficiently.
About the first error:
this is part of the Android API that has not yet been implemented.
This is the reason why it can't find the files.
Now, the second problem is not actually an error, but a warning and shouldn't stop you form compiling.
If it does, it means that in your project you have set the option to make errors from these types of warnings.
You can safely turn this off and completely ignore this warning.

Categories

Resources