After update Android Studio to version 3.2, occurred an errors in one of my projects and it can't compile. I write this project on Kotlin, and also use Data Binding Library. This is one of the errors. The others are similar, and comes from automatically generated classes from Data Binding Library. This is one of the generated classes. You can see that com.helpkarma.campaigns.Data package can't be finded, and because of that, occurs an error in other classes that use this generated class.
I will be very thankful if someone can help me!
Related
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.
In my android app, I had a module labelled base. Inside base were a couple classes which acted as base lifecycle classes(Controller, ViewModel, etc.). My app was working just fine with these class local inside my project. I decided to move those out into their own library so that they could be reused on future projects. So I've published my library via jitpack and now add that library as a dependency in my gradle file.
My issue is that now it seems like all the code has been obfuscated and Koin cannot find definitions for my ViewModel classes. For example, the error I get it
Caused by: h.a.c.f.e: No definition found for 'c.c.a' has been found. Check your module definitions.
I'm using ViewModel{} block to inject my view models in my koin modules but no I don't even know what classes it can not find definitions for because all the code has been obfuscated. Has anyone encountered this and can point me in right direction? The only change I made was delete the local files and publish those files to a library which I now have as a dependency.
The problem resolved itself, I have no idea how or why. I created a new release on my github and used that version and Wa-Lah.
Problem :
I have two Android binding libraries in my solution(C#) and each one of them has specific set of .jar files referring, and these .jar files are from 3rd party. When any one of the binding library is added to the solution then all the classes and interface defined in the .jar files are detected during compile time and everything works perfectly fine but if I add both binding libraries to the solution then there is a conflict between some of the .jar files in both of the binding libraries. Classes, interfaces were not detected and also says assembly reference is missing.
What I have tried ?
1. I have tried putting each of the binding libraries in two different C# library projects and then referring the C# wrapper libraries not directly to the android binding libraries but it is still showing up the same error.
2. I have tried to load the binding libraries using reflection during run-time but I cannot do that because I need to implement interface present in .jar file to my c# class.
Can you please help me how do I resolve this ?
Thanks,
When running Dotfuscator on the release version of my Xamarin.Android app, I'm getting the following errors:
If I disable Dotfuscator, then everything works fine. The weird part is that it works fine on a previous version of the app. In this new version of the app, I only added a handful of Android ContentProviders and one NuGet package. Nothing else. Any ideas?
Update
So as Joe Sewel explains, the issue is not technically with Dotfuscator, but with Xamarin.Android. The system from Xamarin, while generating Java classes, is populating their names from strings pulled from the .NET Intermediary Language files without first checking if those strings can actually be used as Java class names.
In my case, the issue was caused because I had two too many obfuscated C# classes in my project. Dotfuscator was renaming one of my class to do (after going through its normal renaming cycle: ab, ac, ad, and so on). Obviously, do cannot be used as a Java class name because it's a Java reserved keyword, so it caused a syntax error in the Xamarin tools later on. Removing or having Dotfuscator ignore any two classes in my project, caused Dotfuscator not to reach the do name in its cycle, and the issue was fixed. So until this bug is fixed in Xamarin.Android, there is such a thing as obfuscating too many classes in your project.
What appears to be happening is that Dotfuscator is renaming a type to do - which is safe to do for non-library .NET Framework projects, because the .NET intermediate language doesn't reserve this word. Xamarin.Android's "glue" code is then creating Java code based on the obfuscated .NET assembly's type names, and since do is a reserved word in Java, this causes Java compiler errors.
To work around the issue, you could use the Dotfuscator Community user interface to exclude the type that is being renamed.
You can use the renaming map file (e.g., DotfuscatorReports\Release\Renaming.xml) to see the mapping between the original source code names and the obfuscated names, including with the built-in decoding tool.
I work on the Dotfuscator team, and am answering in that capacity. I've also filed an issue with Xamarin, linking to this question, regarding these errors.