Friday, February 10, 2017

How to replace android library project with source code for debugging in android studio

In order to debug the source code of android library project in android studio, the following steps can be used.
1. in android studio's application project, open build.gradle
2. if the library project gradle file is included in it, which means the library project is built into aar file, then comment it out as below
   apply from: "kapsel-plugin-fioriclient/local-smp_fioriclient.gradle"
   //apply from: "kapsel-plugin-attachmentviewer/local-smp_attachmentviewer.gradle"
   apply from: "kapsel-plugin-voicerecording/local-smp_voicerecording.gradle"

   if the library project's gradle file is not specified in build.gradle, then search the project's lib folder to find the jar file, and then rename the jar file to a different name, so that it cannot be loaded

3. add the source file into the main application project. open build.gradle, and search java.srcDirs, include the parent folder of library's "com" source folder in the  folder array as below
java.srcDirs = ['src','/Users/i826633/Documents/source/kapsel/com.sap.mobile.platform.client.kapsel.plugins.android-3.14/attachmentviewer/src/main/java','/Users/i826633/Documents/source/kapsel/com.sap.mobile.platform.client.kapsel.plugins.android-3.14/online/src/main/java','/Users/i826633/Documents/source/kapsel/com.sap.mobile.platform.client.kapsel.plugins.android-3.14/authproxy/src/main/java']

4. sync the gradle and build the project, some error of R. missing resource may happen as only the java source code is added in the main project, and the resource is missing. Just comment out the lines causing the error, or replace the resource id with the actual resource

5. build and run the project

2 comments:

  1. Fan Layout Manager for Android
    Using Fan Layout Manager you can implement the horizontal list, the items of which move like fan blades (in a circular way of a radius to your choice). To give a slightly chaotically effect to the motion, it’s possible to set an angle for the list items. So, every implementation of the library can be unique.
    http://www.tellmehow.co/fan-layout-manager-android/

    ReplyDelete