How to set "Deprecated" to kotlin class and ignore error? - android

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.

Related

Data Binding library - error in automatically generated classes

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!

Kotlin REPL with Android Classes unStub!ed

I like the Kotlin REPL in Idea / Android-Studio - but as an Android Developer I often run into Stub! problems here. When writing unit-tests I am using unmock to work around this problem. Is there a way to use the same method used there for the Kotlin REPL plugin?
[
All android (and java.lang.*) classes are placeholders in an Android project. This is because android does not use standard java class files to store the compiled code and there is no way to directly run this code on a computer.
You simply can't use the REPL with android classes, they will only exist on an actual device or emulator.
If you do not care about correctness, then you can use Robolectric's implementation of Android by adding it as a dependency to the project.
To make sure it does not collide with the actual implementation you should probably do this with a separate module dedicated to the REPL.
Robolectic's dependency used by unmock is: org.robolectric:android-all:7.1.0_r7-robolectric-0
The problem is that the Kotlin REPL in IDEA is provided by the Kotlin IDEA plugin, which has no notion of Android per se, but only looks at what's in the classpath, which in this case is the android.jar containing the stubs that throw the exception you mentioned.
Using unmock or even the integrated Android support for removing exceptions from the stubs in tests (see here at the end of "Mock Android dependencies") won't work as that only affects your Gradle build.
The only solution I can think of is to either open an issue on the Kotlin tracker or dig through the source code of the REPL function in the Kotlin plugin and send a Pull Request.

How do I suppress code generation errors caused by classes which failed to be generated?

Using libraries like Android data binding, Dagger 2, Requery, GreenDAO, and many others, Android project compilation often depends upon classes generated at compile-time.
When mistakes are made that inhibit correct code generation in a large project, instead of seeing the error about that issue highlighted, Android Studio reports errors from hundreds of missing classes and related issues. I have to dig to find the real error embedded among hundreds of lines of missing class errors and related errors and warnings. As the project grows in scope, code generation errors become unmanageable.
Is there any method to inhibit these anticipated errors in cases when code generation goes awry so I can quickly see the cause without digging into false positives?
The real causes of errors contains at gragle build log. You need to open Gradle console. It's looks like on image below:

How to find which library is using a missing class and causing Proguard errors?

Now that Android M has completely removed the Apache HTTP client, I'm finding that some of the libraries I use still depend on or reference it, so while Proguarding, I'm getting errors like:
Warning:org.apache.http.entity.mime.MultipartEntity: can't find superclass or interface org.apache.http.HttpEntity
this question/solution recommends using -dontwarn to suppress the errors and this does allow it build, but I'd rather understand what is using that so I can avoid runtime errors. I can't find references to those classes in my own code, so it must be in libraries. Proguard doesn't give any info on where it saw this class.
Is there a way to better understand where is error is coming from?
Thanks
Have you tried the JarAnalyzer? (http://www.kirkk.com/main/Main/JarAnalyzer)
I'm not 100% sure it works on android JARs, but I'm trying to find a windows machine to test it out right now.
I also found JDepend (http://clarkware.com/software/JDepend.html), still trying to get that one to run as well.

Lint finds warnings in log4j used in Android project

I use log4j in Android project, dependency defined in project gradle like:
compile 'log4j:log4j:1.2.16'
When Lint check happens, the analyser reports "InvalidPackage" errors:
../../../../../../../.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar: Invalid package reference in library; not included in Android: java.awt. Referenced from org.apache.log4j.chainsaw.ControlPanel.
../../../../../../../.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar: Invalid package reference in library; not included in Android: java.awt.event. Referenced from org.apache.log4j.chainsaw.Main.1.
....
How can I fix that the better way?
Lint suggest to supress this warning by id, but this means supressing all warning by the type, am I right? This looks like not the best solution...
Maybe some way to specify lint not to check the log4j package?
awt itself is not supported in Android.
Instead use the native Android graphics as detailed in How to add java.awt.image package in Android and other questions like 25488832: using-awt-classes-in-android
Of course this doesn't help much if you rely on a library which relies on awt . Possibly there is an Android version of such library.
(You may be OK using parts of a library which provokes this error. You can only use parts of the library which do not use awt, else, RTE. For this, your build process would have to tolerate the reaction from Lint. There are likely safer ways around this. )

Categories

Resources