Is it possible to alter the code of a library imported through Gradle in Android Studio? I am thinking it isn't possible since the libraries get added in at runtime?
Is there anything equivalent of extensions in Swift in Java? An extension in Swift is basically a way to add more functions/methods to an existing class. Without directly altering the original source code.
Thanks in advance!
Is it possible to alter the code of a library imported through Gradle in Android Studio?
Not as you are defining it, per your Swift extension reference.
An extension in Swift is basically a way to add more functions/methods to an existing class. Without directly altering the original source code.
Java does not have this, sorry.
Related
Hello I would like to use some function from com.android.dialer.telecom.TelecomUtil inside some java class from an android I'm building but I don't know what dependency I should add to build.graddle to do so
Anyone familiar with this ?
TIA
I don't know what dependency I should add to build.graddle to do so
Assuming that you mean this edition of TelecomUtil, that is not in a library. It is a Java class in the Dialer app from the AOSP.
If you are writing your own AOSP app, such as a custom dialer as part of custom firmware, you can copy TelecomUtil.java into your own project, along with other Dialer app classes that TelecomUtil depends upon (e.g., com.android.dialer.common.LogUtil). Or, copy just the method(s) from TelecomUtil that you need.
If you are writing an ordinary Android SDK app, you can try doing the same thing. You may run into places where the copied code depends upon classes or methods are are not part of the Android SDK, though.
We have one mobile project fully developed in native android using android sdk.
we want to migrate the code base to kotlin completely. So wanted to know what are
main things to keep in mind while migrating to Kotlin.
Before you convert your project from Java to Kotlin keep things in your mind.
Converting from Java to Kotlin will may cause your git track. Refer to avoid this problem
Android studio provide easy way to convert Java code into Kotlin in a automate way [Press Ctrl+Alt+Shift+K]. But it may arise some conflicts like "Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too?". For example in your java file contains static variables. Because kotlin didn't support static. In this case you have to manually correct it. It took some time.
While developing you may maintain many branches. If you converted one file from Java to Kotlin will affect other branch.
I don't recommend to switch full code automatically to Kotlin.
The tool for converting to Kotlin is great but you have to review all code generated by the tool. Sometimes code generated are not really readable.
Java and Kotlin can be use together. You can convert files one by one. You have time to check and clean the converted code.
I want to understand how to write a dynamic library .so for android? This is not the usual linux library, is it? And I want to write my own. For example instead of already lying there. Can anyone help me with this?
You need to use the Android NDK to write native libraries.
I am using a jar file which contains an algorithm I have developed. As it is easy to decompile it, in order to prevent it, I want to convert jar into native code and use it with NDK. How to do it ?
Any other way to do it ?
I'm assuming you've written your algorithm in Java. You must have it in C/C++ to use NDK.
I can see only 2 options:
Write it from scratch in C/C++. Looking at your already written Java code it should be easy, but probably boring and time-consuming.
Try some Java to C++ automatic converters, for example j2c. However, sometimes they're not working, they can change the code behavior, so you need to test it all thoroughly.
Java code obfuscation is good to improve the security of your code from reverse engineering. Try any tools like progaurd
Is there a handy-dandy equivalent to org.apache.commons.beanutils.PropertyUtils on Android?
I can't seem to use bean utils in my android app due to some dependencies on PropertyDescriptor,and IndexedPropertyDescriptor. So I'm wondering if there are any alternatives?
Basically all I want to do is use a method name as a string "someMethod" and feed that into setMethod(anObject, "someMethod", value), much like PropertyUtils does; but without having to resort to the nasties of reflection...
Or are my hands tied and I need to use Reflection?
There is bridge library which works on Android: android-java-air-bridge.jar. Just include into project path and use all apache beanutils features in your Android project as you could use in ordinary java application. Moreover, there are lot of other classes which moved to this Android supporting library. Look at the list.
There is a possibilty to use libraries or write own code depending on the PropertyUtils. But it sure isn't dandy. You can get the general idea about what has to be done in this thread.
There are apparently some projects who have successfully solved the issue, so you can study thier solution. Take a look at Drawingpad-base and libgdx. You can find PropertyUtils in the package com.madrobot.beans in the first project and com.badlogic.gdx.beans in the second.