How to enable static code analysis in AOSP development - android

I want to integrate some code style checker(formatter) tools or lint to do static code analysis on AOSP during development. I believe this can be done in the building process. I'm curious is there anything I can integrate into the AOSP building process for those checks?
Or does it already exist in the building process? If so, can I configure the check rules?
Any docs/ wikis or instructions are appreciated.

Related

How to use module in kotlin Mutliplatform moblie

Hey I am learning Kotlin Multiplatform mobile. I starting learning from the doc. I successfully run the module in android and ios platform, without any problem. Now I want to implement this in real project. I successfully created the module inside my pre-existing android directory. According to this Make your cross-platform application work on iOS we can only use module inside the android directory. I work as android developer and my other team have ios developer. So the problem is we have different system for android and ios. So how can I share this module to the Ios team. Please guide me how to achieve this. I read somewhere ios need XCFramework. But I am not sure, how can I achieved this. Can someone guide me step wise? Thanks
In general, Kotlin Multiplatform Mobile provides you with an ability to build frameworks for iOS. It can be delivered in several ways:
Simple ModuleName.framework file ready to be imported into your teammate's app,
CocoaPods integration, providing your teammate with the ability to rebuild this framework from sources and to use third-party libraries from Kotlin code,
Universal (fat) framework and XCFramework. These two are designed to provide the framework user with the ability to build the result app for different CPU architectures. This would be helpful when publishing the app.
If your aim is to just show the iOS team an example of Kotlin Multiplatform Mobile power, I think it would be enough to declare the framework, build it by executing the appropriate gradle task and share the result file.
If they would also like to put some code into the iOS-specific part of your module, adding the CocoaPods integration will be a good idea.

How to compile Android native library with Android Studio?

I am a new user of android studio and I am developing application based on native library(JNI) and eclipse is provide builder facilities for NDK-build. so any functionality available in android studio to build NDK
NDK integration is very basic, limited, and not documented (per the New Build System page) at the time of this writing. There a couple of examples in the samples at the bottom of that page that illustrate how this can be done. You can also check the Gradle Plugin User Guide periodically to see if any additional documentation is available.
Android Studio runs ndk-build automatically if you have a jni directory in your project root. I describe the minimal setup you need in my answer to a similar question.

Is there a way to use ProGuard with MonoDroid?

Our development team just (mostly) finished an Android app using MonoDroid in Visual Studio. Because it has to do with banking, we wanted to try to obfuscate it in order to add some security against anyone trying to decompile it. Initially, I figured I could just use ProGuard, but there doesn't seem to be a project.properties file that I can edit in Visual Studio. Can anyone shine some glorious helping light on this subject and tell me if it is possible to use ProGuard with Mono and my newbishness is just clouding my vision?
(Another developer tried to use Dotfuscator -since we couldn't immediately find a way to use ProGuard- but it failed with numerous errors; the Mono runtime seems to give it issues.)
The Mono for Android toolchain doesn't have any support for running proguard at the moment.
However, with one broad exception, the lack of proguard support is largely moot. Proguard only runs on Java bytecode. The Mono for Android architecture has the Mono runtime running in the process; .NET CIL is not "compiled" into Java bytecode, the CIL is JITed by Mono. The only Java code running around is for Android Callable Wrappers, which allow Java/Android to call into managed code.
Thus the only thing proguard will protect in a Mono for Android app is the generated Android Callable Wrappers, which largely consists of a bunch of native method declarations. There won't be any business logic to decompile in the Android Callable Wrappers.
Instead, the CIL assemblies are stored uncompressed in the .apk file. The assemblies in turn can be decompiled to obtain all your business logic. The solution here is to obfuscate the assemblies before embedding them into the .apk. There are reports that Xenocode's Postbuild 2010 can be used, though I don't know any of the details on how to hook this up.
The exception mentioned above relates to any custom Java code included in the build proces via the AndroidJavaSource and AndroidJavaLibrary Build actions, which would be used to include such things as the AdMob library. For this scenario we should add proguard support to the build process, though I have no ETA on when proguard support will be added.

Android NDK with Visual Studio

I'd like to build some native libraries for android using the NDK (native development kit), but i'd like to use Visual Studio 2010 to do it. I've googled quite a bit but haven't found any information on it. Does anyone have any experience with this and know the steps necessary to make this happen? I have CYGWin installed, made sure i get Make (per the NDK instructions), but i'm not really sure of the next steps in terms of setting up the project, compiler in visual studio, etc.
If anyone knows of any write-ups, tutorials, or links to sample projects, that would be awesome, as there isn't much on google yet.
thanks!
Here's another solution, which integrates the NDK fully within Visual Studio. No makefiles. It behaves like a proper Win32 project:
Here's an excellent blog post about how you can configure your environment to debug android NDK code using Visual Studio.
Visual Studio is officially not supported.
Some problems (but not limited to):
MSVS cannot create the proper ARM binaries
Android makefiles (.mk) are not supported by MSVS
There are however, third party solutions:
vs-android
VisualGDB
You might want to check out DS-5 as well, though it's not Visual Studio.
The answer depends on what kind of integration you require.
To just build the native Android code from Visual Studio you can create a new Makefile project, and make it run ndk-build.cmd when you press "build". If you would like to get the error messages mapped as well, you will need to parse the output of ndk-build.cmd and convert it to a format that Visual Studio can udnerstand.
If you want to debug your native Android code from Visual Studio, you will need a third party tool that will control ndk-gdb on behalf of Visual Studio and provide workarounds for several bugs (e.g. rebind breakpoints when libraries are loaded).
You can try our VisualGDB for Android tool that does exactly that - creates projects that wrap ndk-build and controls NDK debugger on behalf of Visual Studio. If you need more information, there is a step-by-step tutorial available.
I have not found a direct clean solution, here is my workaround.
I develop my native code on VS as a static library, and use some test project to try it as a console aplication.
When it is ok, from cygwin I use a little bash script that copies all needed files to the jni folder and launch the standard android ndk make command. (also copy some file to assets folder when needed), producing the executable in the right folder.
To use the pthreads I have linked my projects to pthreads-win32.
The only files I do not compile in VS are the jni code.
I hope this can help you.
There's also a couple of other third party alternatives for developing ANdroid apps with VS in addition to those above. There is the open source dot42 located at http://www.dot42.com and Remobjects, http://www.remobjects.com , which allows you to program in c#, Pascal, and Swift. I have played with the trial of Remobjects and am now starting to play around with dot42.
My use of the remobjects trial allowed me to recreate in c# the first five chapter projects in the textbook of the Android course I took. I haven't had the same success with dot42 so far but I need to find some time to really give it a chance.

debugging native code (C++) using gdb on android with Eclipse. Is it possible?

I have some piece of code which uses JNI. I can debug code wrote in Java directly in Eclipse (using ADT). I even have a script, which help me debug native code with gdb. However this is not very comfortable way for doing this.
Is it possible to configure Eclipse to use gdb (I guess gdbserver) for debbuging android native applications? Do you know where I could find any description of this?
according to the release notes from Android 2.2 NDK - you can now debug on device native code.
please refer to the NDK docs, since I didn't try this myself.
It depends whether you want to debug JNI code you have written using NDK apis vs native code in AOSP applications.
For the former case, use NDK debugging tools. For the latter, you need to have right version of gdbserver and gdb. The session needs to be configured with gdb script to find symbols for AOSP libs.
Please check Debugging AOSP native applications link for step by step tutorial.

Categories

Resources