@@ -133,3 +133,41 @@ The Linux build environment used for compiling LiveCode for Android is based on
133133* openjdk-7-jdk
134134* flex
135135* bison
136+
137+ ## Debugging & Profiling with Android Studio
138+
139+ * Build a debug build of the android engine
140+ * Inside android-XXX-bin, create a symlink librevandroid.so -> Standalone-Community
141+ (or Standalone-Commercial; whichever you're using)
142+ * Build your standalone
143+ * Start Android Studio and select "Profile or Debug APK" on the main menu.
144+ * Select the APK you built
145+ * Studio will show you the contents of your APK and there will be a banner
146+ along the top about being unable to find debug symbols. Click it and navigate
147+ to the folder where you created the librevandroid.so symlink.
148+ * Set the paths to the source folders in the panel that appears if you want to
149+ do debugging rather than profiling
150+ * On the top right of the Android Studio toolbar, there are icons for running,
151+ debugging and profiling. Select the one you want.
152+ * If Android Studio complains about the SDK not being set, select the top-level
153+ project in the left-hand tree view, right-click and go to Module Settings. Hunt
154+ through those menus for SDK/API selections and make sure they're set properly
155+ (they may default to "Java 1.8" rather than an Android SDK).
156+ * If Android Studio complains about the app not having a default activity, quit
157+ Studio and restart it. Keep doing this until it stops being stupid.
158+ * If you selected "Profile", you'll see the profiler on the bottom of the
159+ window. Click the "CPU" portion of the graphs. To do a trace, select
160+ "Sample C++ methods" from the drop down and hit Record. Perform the action you
161+ want to profile then click "Stop".
162+ * If profiling says "Advanced profiling not available", you will likely need to
163+ play around with MinimumSDK settings and the like when building the app. In
164+ particular, make sure your device is at least API26 and that the minimum API
165+ level is set to API26 too.
166+ * The threads of interest are the one at the top of the list (the main Android
167+ thread) and one further down called "Thread-2" - this is the engine thread.
168+
169+ > ** Note:** When you import an APK into Android Studio, the IDE creates a new
170+ > project in your home directory under ApkProjects/, and makes a local copy of
171+ > the target APK there. This means that if you rebuild or update the original
172+ > APK, you need to manually import the updated version into Android Studio
173+ > again.
0 commit comments