I'm using joint compilation (having .java files in the groovy src directory) so that java and groovy can reference each other.
However, when using google's data-binding lib, the compiler fails to find the classes referenced in the layout.xml file.
I always get a 'Cannot resolve type for user'
Is there a workaround this ?
Databinding requires annotation processing that Google hides in Android Studio. See this example of how to get it setup for a groovy application https://github.com/pieces029/groovy-android-data-binding
Related
I am trying to user both MediaSoup and WebRTC libraries in my app.
Separately it works flawlessly, but when trying to add both in the same project I have some conflicts.
It's either:
I add both mediasoup ('org.mediasoup.droid:mediasoup-client:3.0.8-beta-3') and webRTC ('org.webrtc:google-webrtc:1.0.32006') in my project, I can sync my gradle. But when trying to build the project, I get an error saying that I got a lot of duplicated class, as such:
Duplicate class org.webrtc.AndroidVideoDecoder found in modules jetified-google-webrtc-1.0.32006-runtime.jar (org.webrtc:google-webrtc:1.0.32006) and jetified-mediasoup-client-3.0.8-beta-3-runtime.jar (org.mediasoup.droid:mediasoup-client:3.0.8-beta-3)
I add only WebRTC library: impossible to use MediaSoup so not a solution
I add only MediaSoup. So far I can compile and even build my app, but it crashes on the first statement where I use WebRTC, on:
PeerConnectionFactory.initialize()
AS is telling me that the native lib is not found:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file ".../base.apk"],nativeLibraryDirectories=[/data/app/dev.arvuz-fuhAdJV_sT2-PQyEHP0vxg==/lib/arm64, /data/app/dev.arvuz-fuhAdJV_sT2-PQyEHP0vxg==/base.apk!/lib/arm64-v8a, /system/lib64]]] couldn't find "libjingle_peerconnection_so.so"
So, that's where I am stuck. How (is it even possible?) to use WebRTC in combination with MediaSoup libraries on Android?
I tried excluding some WebRTC module in my gradle file but couldn't achieve anything.
It's possible that the MediaSoup and webRTC dependencies are using different versions of the same library code under the hood. The namespace of these different versions could collide at runtime when the JVM tries to lookup some native method that's only present in one of the versions. If this is the case, you must use the version of MediaSoup and webRTC that share the same library version.
In Android Studio, I have some classes written in Kotlin that I use only for trivial purposes, and they have a lot of compilation errors, I want to keep them, not compile, and studio doesn't report errors.
How to do it?
Move these classes to another module and do not add to the application gradle.
I'm trying to create bindings for the android sdk provided here https://www.nmi.com/sdks-and-apis#CDNA. The binding project builds, and I can add it into my xamarin android project but as soon as I include it I get the following error/s.
error: package com.creditcall.chipdnamobile does not exist
com.creditcall.chipdnamobile.IApplicationSelectionListener ChipDnaSample.Android
C:\Users\mikee\Documents\GitHub\ChipDna\ChipDnaSample\ChipDnaSample.Android\obj\Debug\90\android\src\mono\com\creditcall\chipdnamobile\IApplicationSelectionListenerImplementor.java 8
error: package com.creditcall.chipdnamobile does not exist private
native void n_onAvailablePinPads
(com.creditcall.chipdnamobile.Parameters
p0); ChipDnaSample.Android C:\Users\mikee\Documents\GitHub\ChipDna\ChipDnaSample\ChipDnaSample.Android\obj\Debug\90\android\src\mono\com\creditcall\chipdnamobile\IAvailablePinPadsListenerImplementor.java 33
There are 64 errors of the same nature just referencing different classes. I've put all the code on GitHub here
If I go into Obj/Release/generated/src I can find IApplicationSelectionListener so it is created some binding but it doesn't actually work. Could someone point me in the right direction about what I need to do to correct errors such as these?
Thanks
You have to change the build type of the jars. The java compile can't find it, because it's not present at compile time.
Change
InputJar to EmbeddedInputJar for ChipDnaMobile.jar
ReferenceJar to EmbeddedReferenceJar for CardEaseXMLClient.jar
For more info see: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-a-jar
The important sentences:
Typically, you use the EmbeddedJar build action so that the .JAR is automatically packaged into the bindings library. This is the simplest option – Java bytecode in the .JAR is converted into Dex bytecode and is embedded (along with the Managed Callable Wrappers) into your APK. If you want to keep the .JAR separate from the bindings library, you can use the InputJar option; however, you must ensure that the .JAR file is available on the device that runs your app.
I need to use http://viewpagerindicator.com/ to add static tabs below the actionbar on a Xamarin.Android project.
I downloaded the project and migrated it from maven to gradle to build it into an AAR file suitable for Xamarin consumption. I created a java binding project, added the AAR file as a LibraryProjectZip and added the v13 support jar as a ReferenceJar but it seems it is being lost somewhere in the way as evidenced by these xbuild logs:
BINDINGSGENERATOR: warning BG8C00: For type Com.Viewpagerindicator.IPageIndicator, base interface android.support.v4.view.ViewPager.OnPageChangeListener does not exist.
BINDINGSGENERATOR: warning BG8800: Unknown parameter type android.support.v4.view.ViewPager.OnPageChangeListener in method SetOnPageChangeListener in managed type Com.Viewpagerindicator.IPageIndicator
BINDINGSGENERATOR: warning BG8800: Unknown parameter type android.support.v4.view.ViewPager in method SetViewPager in managed type Com.Viewpagerindicator.IPageIndicator
The warnings chain continues for a long time, ending the process with a severely limited port
as the missing types make the methods depending on them to vanish away.
If i remove the support jar, the build fails because of missing classes from a utility named jar2xml, leading me to believe it is only used for part of the compilation/mapping process.
The support jar was taken from an unmodified android sdk at extras/android/support/v13/android-support-v13.jar.
Any help is most welcome.
There is a workaround to make these things work.
In my example, I had 2 reference jars (android-support-v4.jar and google-play-services.jar).
So if you just add these 2 jars with Build Action = ReferenceJar, you will see same errors as you posted.
BINDINGSGENERATOR: warning BG8800: Unknown parameter type com.google.android.gms.maps.model.Marker in managed type Com.Google.Maps.Android.MarkerManager.
Though the Marker and MarkerManager classes are defined in the jars, they're not getting resolved correctly on the C# side. To fix that you need to do is to just add already compiled C# bindings for these jars as references.
In my case I used Xamarin.GooglePlayServices package which had a dependency Xamarin.Android.Support.v4 (exactly as my jars).
In your case, you just need to add Xamarin.Android.Support.v4 package to your binding project.
In the end you will have something like this in your project structure:
Hope that helps!
I'm attempting to build a unit test on Android which utilizes the mockito-all-1.8.5.jar file from mockito.org. I added the jar file to my project using project > properties > project build path > add external jar. This has always worked for me on non-Android java projects.
However, when I run the unit test, I get the following class not found exception:
java.lang.ClassNotFoundException: org.mockito.runners.VerboseMockitoJUnitRunner
Above it is the following message:
Cannot load class. Make sure it is in your apk. Class name: 'org.mockito.runners.VerboseMockitoJUnitRunner'. Message: org.mockito.runners.VerboseMockitoJUnitRunner
I checked the jar and the class is there.
I also tried adding according to this link:
How to use and package a JAR file with my Android app?
But, still no luck. How can I get this class to be found?
Edit: I'm thinking there is a problem with whatever libraries Mockitto depends on - they may not be compatible with the Dalvik jvm. See this post:
http://daverog.wordpress.com/2009/12/14/why-android-isnt-ready-for-tdd-and-how-i-tried-anyway/
1) Import a mocking framework (e.g. mockito) into the project as an additional dependency.
Any imported jars containing class files not compiled to Dalvik bytecode (most) will not work. Attempting to compile the source along with your project will not work either because most libraries will make extensive use of parts of the Java language not compatible with Dalvik: it uses its own library built on a subset of the Apache Harmony Java implementation.
If you are executing inside the Dalvik JVM you won't be able to use Mockito.
If you are running your unit tests on your desktop JVM however (with a testing framework like Robolectric for example) then you are good to go. I am combining the two on my Android projects at present, to good effect.