Xamarin Android Binding Library org.apache issue - android

original Android Jar library file (mposlitesdk.jar) has inside this subfolders content:
com (which has inside subfolder "ingenico" and "zebra")
META-INF
org (which has inside subfolder "apache" with subfolder "commons" and "http")
Library is compiled with target 23 (Android 6.0).
Library mposlitesdk.jar is defined (as usually) as embedded jar
Compiler gives me:
J2XA006 warnings about org.apache.http package which is inside the
library
1>JARTOXML : warning J2XA006: missing class error was raised while
reflecting com.ingenico.pclutilities.PclUtilities :
com/hoho/android/usbserial/driver/UsbSerialPort 1>JARTOXML : warning
J2XA006: missing class error was raised while reflecting
org.apache.http.impl.client.DefaultRequestDirector :
org/apache/commons/logging/Log 1>JARTOXML : warning J2XA006: missing
class error was raised while reflecting
org.apache.http.impl.client.HttpAuthenticator :
org/apache/commons/logging/Log 1>JARTOXML : warning J2XA006: missing
class error was raised while reflecting
org.apache.http.impl.client.cache.ehcache.EhcacheHttpCacheStorage :
net/sf/ehcache/Ehcache 1>JARTOXML : warning J2XA006: missing class
error was raised while reflecting
org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage
: net/spy/memcached/OperationTimeoutException 1>JARTOXML : warning
J2XA006: missing class error was raised while reflecting
org.apache.http.impl.conn.HttpConnPool :
org/apache/commons/logging/Log 1>JARTOXML : warning J2XA006: missing
class error was raised while reflecting
org.apache.http.impl.conn.HttpPoolEntry :
org/apache/commons/logging/Log 1>JARTOXML : warning J2XA006: missing
class error was raised while reflecting org.apache.http.impl.conn.Wire
: org/apache/commons/logging/Log 1>JARTOXML : warning J2XA006: missing
class error was raised while reflecting
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager :
org/apache/commons/logging/Log
strange invalid tokens with char ' are added to generated sources:
obj\Debug\generated\src\Org.Apache.Http.Impl.Client.AbstractAuthenticationHandler.cs(244,65,244,66):
error CS1519: Il token '`' nella dichiarazione del membro di classe,
struttura o interfaccia non è valido
Maybe main issue is about org.apache.http which is duplicated in Xamarin Android namespace?
Thanks for any suggestion
Log is attached

The issue at hand from first glance is that org.apache.http is not playing nicely under API 23. Here's why:
https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client
Google removed org.apache.http and moved it to an optional library. What does that mean for Xamarin.Android? Well it means that it is no longer bound in API 23 since Google doesn't ship it with android.jar. Thus there's a couple workarounds that you can go about:
1) Use any API level between 9-22 (Xamarin.Android will have bindings for this)
2) Add the org.apache.http.legacy.jar to your Binding project as a ReferenceJar if you want to satisfy dependencies and not create C# bindings for it. Or use EmbeddedReferenceJar if you want to embed the .jar and create C# bindings for it.
You can find this .jar in the following location:
android-sdk\platforms\android-23\optional (Or any API level above 23 like API 24/etc will have it)

Related

"MissingRegistered" Lint warnings when using com.google.android.material.* UI components

I'm trying to get rid of the Lint warnings in my Android project. Doing so I run into the following type of warning messages that I do not understand:
app\src\main\res\layout-land\event_settings_fragment.xml:25: Error: Class referenced in the layout file, com.google.android.material.textfield.TextInputLayout, was not found in the project or the libraries [MissingRegistered]
<com.google.android.material.textfield.TextInputLayout
^
My app seems to be running fine, so the com.google.android.material.textfield.TextInputLayout class should be available in the project?
Note that I do get this warning on all com.google.android.material.* classes.
MissingRegistered
Summary: Missing registered class
Priority: 8 / 10
Severity: Error
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable MissingRegistered
If a class is referenced in the manifest or in a layout file, it must also
exist in the project (or in one of the libraries included by the project. This
check helps uncover typos in registration names, or attempts to rename or move
classes without updating the manifest file properly.
See: http://tools.android.com/tips/lint-checks
If you ensure that the layout file runs without problems, you can disable the check:
app/build.gradle
android{
lintOptions{
disable "MissingRegistered"
}
}
or add tools:ignore="MissingRegistered" in the layout file to suppress the check.

java internal interface in class throw Invalid parameter type error in xamarin android binding

after
I put the aar file in the binding project
add the v7appcompact nuget package
add the v7.recycle... nugget package
build the binding project
The vs throw the warning build log and errors:
1>------ Rebuild All started: Project: CalendarViewDebugBinding, Configuration: Debug Any CPU ------
1>JARTOXML : Java HotSpot(TM) 64-Bit Server VM warning : ignoring option UseSplitVerifier; support was removed in 8.0
1>BINDINGSGENERATOR : warning BG8801: Invalid parameter type com.henry.calendarview.SimpleMonthView.OnDayClickListener in method ViewHolder in managed type Com.Henry.Calendarview.SimpleMonthAdapter.ViewHolder.
1>BINDINGSGENERATOR : warning BG8C00: For type Com.Henry.Calendarview.SimpleMonthAdapter, base interface com.henry.calendarview.SimpleMonthView.OnDayClickListener is invalid.
1>D:\TempApps\CalendarViewDebugBinding\CalendarViewDebugBinding\obj\Debug\generated\src\Com.Henry.Calendarview.SimpleMonthAdapter.cs(1105,86,1105,104): warning CS0114: 'SimpleMonthAdapter.OnCreateViewHolder(ViewGroup, int)' hides inherited member 'RecyclerView.Adapter.OnCreateViewHolder(ViewGroup, int)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword.
1>D:\TempApps\CalendarViewDebugBinding\CalendarViewDebugBinding\obj\Debug\generated\src\Com.Henry.Calendarview.SimpleMonthAdapter.cs(9,23,9,41): error CS0534: 'SimpleMonthAdapter' does not implement inherited abstract member 'RecyclerView.Adapter.OnCreateViewHolder(ViewGroup, int)'
1>D:\TempApps\CalendarViewDebugBinding\CalendarViewDebugBinding\obj\Debug\generated\src\Com.Henry.Calendarview.SimpleMonthAdapter.cs(9,23,9,41): error CS0534: 'SimpleMonthAdapter' does not implement inherited abstract member 'RecyclerView.Adapter.OnBindViewHolder(RecyclerView.ViewHolder, int)'
1>D:\TempApps\CalendarViewDebugBinding\CalendarViewDebugBinding\obj\Debug\generated\src\Com.Henry.Calendarview.SimpleMonthAdapter.cs(17,95,17,124): error CS0535: 'SimpleMonthAdapter.CalendarDay' does not implement interface member 'IComparable.CompareTo(Object)'
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
So I go to the GitHub source project to find the type OnDayClickListener and found it is an interface in the SimpleMonthView class.
And,so , how to fix this build warning ?
here the aar(name is 'library-debug.aar ') file I put in GitHub :
The_File
and here is the source project in GitHub :
henry-newbie/CalendarView
At last I Use another library instead:
dengshiwei/CalendarComponent

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

Xamarin binding jar couldn't load classes

I followed the steps Binding a Jar Library.However, once I complie the process ,hundreds of warning was shown to me ,most of it were "couldn't load class" warning. I don't know what should I do.
The version of Xamarin is 5.9.5(build 10).
I'm sorry I haven't enough reputation to post the image. I copied some warning messages here.
D:\project_c#\Android\OsmDroid\OsmDroid\JARTOXML: Warning J2X9001: Couldn't load class microsoft/mappoint/TileSystem : java.lang.ClassNotFoundException: microsoft.mappoint.TileSystem (J2X9001) (OsmDroid)
D:\project_c#\Android\OsmDroid\OsmDroid\JARTOXML: Warning J2X9001: Couldn't load class net/wigle/wigleandroid/ZoomButtonsController$1 : java.lang.ClassNotFoundException: net.wigle.wigleandroid.ZoomButtonsController$1 (J2X9001) (OsmDroid)
D:\project_c#\Android\OsmDroid\OsmDroid\JARTOXML: Warning J2X9001: Couldn't load class net/wigle/wigleandroid/ZoomButtonsController$OnZoomListener : java.lang.ClassNotFoundException: net.wigle.wigleandroid.ZoomButtonsController$OnZoomListener (J2X9001) (OsmDroid)
Try setting the $(AndroidClassParser) MSBuild property to class-parse:
xbuild /p:AndroidClassParser=class-parse
or manually add the property to your .csproj
see - https://gist.github.com/prashantvc/09116d89ec5c8c4d4680d2b956862c0c#file-binding_sdkbase-csproj-L17

Couldn't parse API file "frameworks/base/api/current.txt"

I tried adding some files in Android framework. Everything goes well, except in the end of compilation i am getting below error.
I tried make update-api too, but no luck, every time in compilation it is giving below errors. If anybody know how to overcome this, please let me know.
Docs droiddoc: out/target/common/docs/doc-comment-check
Checking API: checkapi-last
Checking API: checkapi-current
host layoutlib_create: out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
Couldn't parse API file "frameworks/base/api/current.txt"
...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
...as XML: com.google.doclava.apicheck.ApiParseException: Error parsing API
Couldn't parse API file "out/target/common/obj/PACKAGING/public_api.txt"
...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
...as XML: com.google.doclava.apicheck.ApiParseException: Error parsing API
Exception in thread "main" java.lang.NullPointerException
at com.google.doclava.apicheck.ApiCheck.checkApi(ApiCheck.java:118)
at com.google.doclava.apicheck.ApiCheck.main(ApiCheck.java:67)
******************************
You have tried to change the API from what has been previously approved.
To make these errors go away, you have two choices:
1) You can add "#hide" javadoc comments to the methods, etc. listed in the
errors above.
2) You can update current.txt by executing the following command:
make update-api
To submit the revised current.txt to the main Android repository,
you will need approval.
******************************
Couldn't parse API file "out/target/common/obj/PACKAGING/public_api.txt"
...as text: com.google.doclava.apicheck.ApiParseException: missing class or interface. got: private line 6342
...as XML: com.google.doclava.apicheck.ApiParseException: Error parsing API
Exception in thread "main" java.lang.NullPointerException
at com.google.doclava.apicheck.ApiInfo.isConsistent(ApiInfo.java:60)
at com.google.doclava.apicheck.ApiCheck.checkApi(ApiCheck.java:118)
at com.google.doclava.apicheck.ApiCheck.main(ApiCheck.java:67)
******************************
You have tried to change the API from what has been previously released in
an SDK. Please fix the errors listed above.
******************************
make: *** [out/target/common/obj/PACKAGING/checkapi-last-timestamp] Error 38
make: *** Waiting for unfinished jobs....
make: *** [out/target/common/obj/PACKAGING/checkapi-current-timestamp] Error 38
-rw-r--r-- 1 aankit admin 9763299 Jan 31 14:21 out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
Output: out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
Input : out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar
Input : out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
Found 7983 classes in input JARs.
Found 2260 classes to keep, 2143 class dependencies.
# deps classes: 2143
# keep classes: 2260
# renamed : 19
Created JAR file out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
The reason for this issue was ,
Cause :- I was adding private classes in Android Frameworks and these classes documentation/declarations must be added to “frameworks/base/api/current.txt”
Solution :- as per error logs, There are two solutions.
1) add #hide annotation in each method's Signature in each newly added file and its members.
2) use commands $ make update-api then $ make -j4 or either use $make update-api && make -j4 , and code should be compilable now.
Have you tried to compile you code before updating api? It seems that the code you've added cannot be compiled.
The problem is that new api cannot be parsed.
If you check external/doclava/src/com/google/doclava/apicheck/ApiFile.java you'll find the the throw statement that can help you:
throw new ApiParseException("missing class or interface. got: " + token, tokenizer.getLine());
It seems that you try to add to api private class or interface that is not allowed. To check this try to look into out/target/common/obj/PACKAGING/public_api.txt file line number 6342. There you should find the name of the class or interface that causes the error.

Categories

Resources