Does Kotlin provide any additional security? - security

When we develop an Android app in Java, we have the option to obfuscate the code and built the APK.
Is there any advance feature in Kotlin to do the same?

Code obfuscation is neither a Java feature nor a Kotlin one.
Since Kotlin is compiled to the same bytecode as Java, you can use the same tools (for example Proguard). Those tools obfuscate the bytecode and not the sources, I think you misunderstood that.

Suppose you're running gradle build on your Kotlin Android project. Then you'll find following tasks being run:
:app:compileReleaseKotlin
:app:compileReleaseJavaWithJavac
:app:copyReleaseKotlinClasses
:app:compileReleaseSources
:app:transformResourcesWithMergeJavaResForRelease
:app:transformClassesAndResourcesWithProguardForRelease
:app:transformClassesWithDexForRelease
As you can see Kotlin sources are compiled first, then the Java sources. This results in only one collection of Java classes which are processed with Proguard; just at the end. There is no differentiation between Java and Kotlin anymore at this step.

Related

Possible to use a static library built from a different Android NDK?

The Android app I am working on is completely written in C++. I need to integrate it with a static library that also is written in C++. There is no dependency on STL in any of the projects.
The static library uses cmake to build. Unfortunately, the app is based on an old AOSP version of Android NDK and has no support for cmake.
I also have a newer version of Android NDK in a different directory. This version does support cmake toolchains.
I am thinking I will build the static library against the new NDK and use it in my main project. The ABI is the same for both the projects - armv7a.
I have tested this logic with a sample code. It seems to work. I am able to invoke methods in the static library from my main app.
Also, there are no name-mangling issues.
The question I have is if there is any issue I am overlooking.
I am thinking it should not matter that the compilers used to build the sources are different. As long as they are producing arm-compatible code, I should be able to able to integrate them.
As a matter of fact, another library that I am using, gstreamer, is available for download as pre-built binaries at https://gstreamer.freedesktop.org/data/pkg/android.
Please advice.
For those interested, mixing NDKs doesn't seem to be an issue as long as you follow certain guidelines. Some of them are listed at https://developer.android.com/ndk/guides/cpp-support.
Essentially, there is no problem if your project is 'C' based. However, if you are using C++, you must not use STL.
I have managed to build part of my code with two NDKs and I am not seeing any link time or runtime errors.

Can I generate an unsigned APK using dexguard?

My question is quite simple but it seems I cannot find the answer on the web and since dexGuard does not have a trial period I cannot test it myself.
Can I generate an unsigend apk obfuscated/encrypted with dexguard in Android Studio. I've been told that is not possible because the signature is used during the obfuscation/encryption process but I feel like I'm missing something.
I would like to know if I can obtain the same result I obtain with "assemble release" gradle task with proguard enabled but using dexguard instead for a better protection.
Thank you for your help
Dexguard is a better version than Proguard so it has all the functionalities that has its little brother. From the Dexguard docs:
The procedure for building Android applications and libraries remains
the same. You can invoke gradle with the usual targets, such as
assemble, build, install, and connectedInstrumentTest. For instance,
to build the release version of your application and install it on a
connected device:
gradle installRelease
To build the release version of a library:
gradle assembleRelease
Debug builds use debug settings, without
optimization or obfuscation. Release builds use release settings, with
full optimization and obfuscation. Applications can optionally be
signed. The entries in application archives are always zip-aligned for
efficiency.
Additionally you can use the Standalone version which makes DexGuard run from the command line. By using this you can post-process an existing Android application (.apk file).
I only use Dexguard to obfuscate a Library in Standalone mode but I am pretty sure it will work.

How do I incorporate robolectric into an existing Android Studio project?

The android ecosystem, particularly Android Studio, has been changing a lot over the last year or so. I've found many sets of instructions for incorporating robolectric into a project, written at many points during that period. And I haven't yet made one work on my project.
Which commands do I need to add to my app build.gradle?
Which commands do I need to add to my project build.gradle?
Do I need to use Junit 4 in order to use robolectric?
Are there other libraries needed? What versions?
Do my tests need to be in src/test rather than src/androidTest?
What other information do I need?
I'm using:
Android Studio 1.1.0
gradle 1.1.0
junit 4.12
hamcrest-library 1.3
mockito-core 1.10.19
dexmaker 1.0
dexmaker-mockito 1.0
I suppose that you expect to run tests from Android Studio in addition to be able run them from command line only.
I think the most up to date example of usage Robolectric with latest android gradle plugin is this.
One note: I see dependencies to dexmaker and dexmaker-mockito that gives me assumption that you use Instrumental tests instead of plain junit tests.
It is quite dumb answer with just reference but I can not be more specific until you have specific issue

Is it possible to compile MonoTouch projects with languages other than C#?

How would I go about using F# or J# for instance? I'm not sure what to get to grips with in the project's compiler settings.
Is there a sequence of command line steps I could follow to compile a MonoTouch project that I might interpret to replace the C# step but tell the other compiler to use the correct platform details etc?
Thank you.
Unfortunately, no. In the book "Developing C# Apps for iPhone and iPad using MonoTouch" you could see text (proof):
C# Is Currently the Only Language
Additionally, currently, the only .NET language available for writing MonoTouch applications is C#.
Nothing changed since that book publication.
Maxim Korobov is right, MonoDevelop only supports C# when writing for MonoTouch.
But this is not the whole truth: MonoDevelop also has (preliminary) support for Portable Library Projects (PLP). What this means is that you can create and compile PLP projects in Visual Studio (in any language Visual Studio supports for PLP projects), and then reference that library in MonoDevelop. Just have in mind that the PLP support is preliminary right now, and you might run into a few bumps on the way.

C/C++ iOS to Android

I have a game written in C/C++ for iOS (using only obj-c for the GLES initialization) and I would like to port it to Android, I saw that it was possible using the NDK by creating a dynamic library (.so).
I install the Android SDK and NDK compile a simple library load it run, no problem, but I simply can't debug it... I can only debug the Java part (where my GLES context is created etc...) Am I missing something or? how can I debug my dynamic library?
It doesn't seems to have no support for debugging anything created with the NDK for Eclipse... so how am I suppose to debug my C/C++ then?
Anybody have experience with this? Any help would be greatly appreciated!
You have to use ndk-gdb. Take a look at this articles:
http://groups.google.com/group/android-ndk/web/debugging-through-the-jni-with-android-2-2
http://www.eclipse.org/sequoyah/documentation/native_debug.php

Resources