How to effectively add dependency .aar file in Xamarin project? - android

I am trying to create a Xamarin project using PayTM android library. Since PayTM doesn't have a direct Xamarin binding I have added the appinvokesdk-1.2.aar in the Xamarin Android Biding library project. The build action for appinvoke is "LibraryProjectZip". Now the appinvoke library also have a runtime dependency on easypay-8.7.3-appinvoke.aar (I found this after checking the pom file for appinvoke.aar file). I have set the build action for the easypay aar file as "EmbdedJar". I have also tried setting it to "LibraryProjectZip","ReferenceJar" and "EmbeddedReferenceJar". During runtime I am getting the error as
Java.Lang.ClassNotFoundException: Didn't find class "easypay.listeners.WebClientListener" on path: DexPathList[[zip file "/data/app/com.edmatix.poc.paytmdemo1-WQf3uMctjbNHoAG_ZfsH3A==/base.apk"],nativeLibraryDirectories=[/data/app/com.edmatix.poc.paytmdemo1-WQ…}
Here is my environment details
Visual Studio for Mac 8.5.4 (Build 12)
AndroidX assemblies
Xamarin.Form 4.6.0.726
Android Minimum API version 22
Android Target API 28 (Android 9)
the class easypay.listeners.WebClientListener is only required during run time and not during compile time.
Can you please help about how to properly embed the dependency library?
Thanks

so this is what I did to solve the issue of missing .aar file during runtime. I added the second .aar file (easypay-8.7.3-appinvoke.aar) into another Xamarin binding project (as shown in here) and set the compile type as LibraryProjectZip. And that solved my issue with not finding the class in runtime.
Thanks

Please try to install Xamarin.Kotlin.StdLib in your Xamarin Android project. Installing the Kotlin package worked for me because I was using the .aar file which contains Kotlin code.
Install-Package Xamarin.Kotlin.StdLib -Version 1.3.50.1

Related

GoogleMaps.LocationServices NuGet package says namespace could not be found

I am creating an android application using Xamarin on Visual Studio 2017. I am trying to use the NuGet package GoogleMaps.LocationServices using this guide (http://www.c-sharpcorner.com/blogs/find-latitude-and-longitude-using-c-sharp1). I have installed the package fine
But when I try to use the package on my code like the guide I following does I just get an error saying it can't find the namespace:
This means that I cannot create a GoogleLocationService() object which is what I need to do to create a Google Maps pin point using a list of location addresses.
Anyone got any idea why I'd be getting this error? Unsure if I just need to use a different namespace now as this guide was from 2013.
The GoogleMaps.LocationServices 1.2.1 NuGet package contains an assembly for .NET 4.0 and no other target frameworks. So it does not support Android projects. NuGet will not add a reference to the GoogleMaps.Gelocation assembly since it is in the lib/net40 directory so it not considered compatible.
Instead I would take a look at the Xamarin.GooglePlayServices.Location NuGet package.
Looking at the content of the NuGet package it has a content file GoogleMaps.LocationServices.readme.txt which seems to be why you can install it into a Android project. This GoogleMaps.LocationServices.readme.txt file is added to your project.
Ideally the NuGet package should have a readme.txt file in the root of the NuGet package and not add a file to the project. Such a readme.txt file would be automatically opened on installation by Visual Studio without the need to add anything to the project. Removing the content file would also prevent the NuGet package from being installed into an Android project, or any other unsupported project type.
The older GoogleMaps.LocationsServices 0.9.0 can be installed into an Android project but that seems to be because the NuGet package is not packaged correctly. The GoogleMaps.Gelocation assembly in this version of the NuGet package is in the lib directory and does not indicate any target framework so it is allowed in all project types, which does not seem to be correct.
It's hard to trace what a new signature of the methods are in 2017, but from my brief look if you change the version on a package to
0.9.0 and use namespace
using GoogleMaps.Geolocation;
The example should work.

How to Configure AspectJ in Android Studio

I am trying to configure AspectJ in Android Studio. But after all trial and error its not working ! Surprisingly I am able to make it work with Eclipse Kepler version The steps I followed for Android Studio
Created sample Android Project
File > Settings > searched for AspectJ in Plugin section
Assuming nothing more to be done in Studio , except configuration of build.gradle files
Added compile 'org.aspectj:aspectjrt:1.8.1' to the to the build.gradle (Module:app)
Created Analytics_onBackPressed.aj for back button press detection
Created Analytics_OnClick.aj for click events detection
Created Analytics_onCreate.aj for components oncreate event detection
Created necessary dependency classes which the above mentioned *.aj classes will internally call
Added required permissions in Manifest
Running the project is not detecting any of the events (button click, oncreate or back button click)
Followed these links ReferenceLinkOne , ReferenceLinkTwo and ReferenceLinkThree
My Question is what is more required to make AspectJ working with Android Studio
Steps followed in Eclipse and got AspectJ working
Downloaded Eclipse Kepler version
Through Install New Software option searched for http://download.eclipse.org/tools/ajdt/43/update
Installed AspectJ Development Tools (Required) .
Created sample android project
Created Analytics_onBackPressed.aj for back button press detection
Created Analytics_OnClick.aj for click events detection
Created Analytics_onCreate.aj for components oncreate event detection
Added required permissions in Manifest File
Right clicked in project and converted project to AspectJ by the following
Configured Java build path with AspectJ runtime library
Now while running the project, I am able to detect components oncreate, back button press
Environment Used
Android Studio : 2.1.2
JRE : 1.8.0
Windows 7 Enterprise
Any help is highly appreciated!
EDIT : 1 , From the output , still AspectJ is not properly configured
As per this link , I created jar file from eclipse including *.aj files and corresponding dependency. Excluded AndroidManifest.xml while creating jar file and created jar
Created Project in Android Studio. Placed this *.jar file in libs file. (apps> libs). I have enabled AspectJ waving as shown below
Now searched the properties for AspectJ and enabled
Now running the project, should be creating logs I had put in *.aj files which is in plugin . Unfortunately these logs are not printed in Android Studio logs.
Form which I am concluding still AspectJ is not enabled in this project OR there is a configuration error
Disclosure: I am the author of the inofficial AspectJ weaver plugin.
As noted in the AspectJ weaver plugin documentation, the plugin does not support compiling .aj files.
To use this plugin, you have two options:
Switch from .aj to annotation style aspects.
Compile the .aj files outside the IDE (IntelliJ Community / Android Studio), for example using Maven/Gradle/Ant, and package them into a .jar. Include this .jar as a dependency in your project and click the Search for aspects... button, as per the documentation.
I have had various success trying to get AspectJ working in Android Studio. This link helped me get part of the way there (assumes Gradle build setup for your project). http://fernandocejas.com/2014/08/03/aspect-oriented-programming-in-android/
Using the custom block of code in the build.gradle file, I was able to get aspects defined using annotations in .java files compiling and weaving properly in my project. However, this same method did not work for me when defining native aspects using .aj files. I hope it helps.
IntelliJ has no tooling support for AspectJ, and Annotation Style AspectJ can work on Android studio. Just treat the aspect code as Java code.
For detail read this issue
aspectj for Android studio - where is AJDT plugin
Also, you can use gradle plugin aspectjx which can weave kotlin code and demo is here

How to add "Android Design Support Library" to Eclipse with ADT-plugin?

The Android Developers Blog announced in May 2015:
The Design library is available now, so make sure to update the Android Support Repository in the SDK Manager.
I am using Eclipse (Version: Luna 4.4.2) with latest ADT-plugin and don't see anything "design" in the SDK manager:
When trying to use android.support.design.widget.FloatingActionButton or android.support.design.widget.NavigationView in my projects like this one -
I unfortunately get errors:
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.NavigationView" on path ...
If I would be using Android Studio, I probably needed the line
compile 'com.android.support:design:22.2.0'
but how to fix this in Eclipse? Can I download a JAR file for the design library?
I have searched \sdk\extras\android\support\ path, but haven't found any.
Before use the design support library, you have to import support-v7-appcompat library from android-sdks\extras\android\support\v7\appcompat. Then, you have to:
create an android library project in eclipse for design support library
put the contents of directory android-sdks\extras\android\support\design in the design support library project
Link appcompat-v7 library to design support library project
Link support library project from your project.
Note: If you can't find the design folder you might want to try this location instead:
android-sdk\extras\android\m2repository\com\android\support\design
You can not use directly the jar android-support-design.jar because you need some resources too (this is the reason of aar format).
For more info just check Error in styles_base.xml file - android app - No resource found that matches the given name 'android:Widget.Material.ActionButton'

Change Android Studio doclet version

I need to generate the javadoc for a Library in Android Studio.
The problem is that, when I start to create the doc, I see the following logs:
Constructing Javadoc information...
Standard Doclet version 1.8.0_31
Building tree for all the packages and classes...
[...]
1 error
javadoc: error - com.sun.tools.doclets.internal.toolkit.util.DocletAbortException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for java.lang.FunctionalInterface not found
I don't know exactly what is the problem. I think it is the doclet version (it takes by default 1.8.0_31); I tried to modify it but I did not succeed... any help?
I am using Mac OSX and Android Studio 1.2.2

android project with odatajclient library gives runtime error

I am developing android application using odatajclient library . App works fine if I build it through maven android plugin . But when I create android project and provide all the dependencies at runtime I am getting following class not found error
05-05 14:40:10.895: E/AndroidRuntime(14596): java.lang.NoClassDefFoundError: org.w3c.dom.bootstrap.DOMImplementationRegistry
Can anyone help me on this please?
I was able to resolve it by using apache olingo and the following sample:
https://github.com/Tirasa/olingoClientOnAndroidSample
When you initially run maven, it produces single jar for android client, which works perfectly fine at least for me.
IF you are using Eclipse (Juno or above) : Right Click->properties->Build path->order export
Here select all the libraries. It will not be sufficient to just add the libraries through libraries.

Categories

Resources