Thursday, November 21, 2019

Compile WebRTC VoiceEngine for SM android(Revisited)

Back in 2015 I had compiled WebRTC codebase for android as I needed WebRTC's VoiceEngine library for android. Link given below.


The library compiled then was 32 bit only and starting August 2019 Google has mandated to include support for 64 bit native libraries.
Thus, there was need to recompile the codebase and generate the said library again.
For this, I have used the same VM as explained in link above.

This time, I used VirtualBox 6 and MacOS Mojave 10.14.6.
Initially I faced an issue importing the the VM file(Ubuntu-14.04.2.ova) but installing VirtualBox extension pack did the trick and the VM came back to life.
Another issue I faced was that Chrome browser being used on the VM Ubuntu was quite old and wasn't responding, I wanted to upgrade but I don't the remember the password for the VM :P
I followed this tutorial to reset the password and succeeded.

Next steps remain invariably the same except for 1 modification for 64 bit and 1 correction.

cd Documents/work/android/webrtc/webrtcFresh/
export PATH=`pwd`/depot_tools:"$PATH"
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
#for 32 bit devices below command
export GYP_DEFINES="OS=android"
#for 64 bit devices below command
#export GYP_DEFINES="OS=android target_arch=arm64 target_subarch=arm64"
cd /home/azhar/Documents/work/android/webrtc/webrtcFresh/WebCRT/src

. build/android/envsetup.sh
export GYP_DEFINES="build_with_chromium=0  $GYP_DEFINES"
export GYP_DEFINES="build_with_libjingle=1 $GYP_DEFINES"
export GYP_DEFINES="libjingle_java=1 $GYP_DEFINES"
export GYP_DEFINES="enable_tracing=1 $GYP_DEFINES"

gclient runhooks

  • The above command generates all the ninja files required to build the webrtc libs. Path of ninja files is as mentioned below:-
for debug mode - WebCRT/src/webrtc/obj/Debug/webrtc/
for release mode - WebCRT/src/webrtc/obj/Release/webrtc/
above path is incorrect,
corrrect path-WebCRT/src/out/Release/obj

Before building the libs edit the libwebrtc-jni.ninja to remove the -fno-rtti flag from cflags_cc parameter, it is required because some additional code is added in the JNI wrapper to make it work with SabaMeeting.

ninja -C out/Debug #builds in debug mode
ninja -C out/Release  #builds in Release mode

  • Post successful builds the final libwebrtc-jni.so will get generated at
/Documents/work/android/webrtc/webrtcFresh/WebCRT/src/webrtc/examples/android/media_demo/libs/armeabi-v7a

  • Incase the jni wrapper needs to be modified, media_demo/jni contains the JNI wrapper.

Note: Important point to note here before beginning is that the WebRTC codebase should not updated, as the WebRTC implementation has changed significantly and I could not find the VoiceEngine library in the latest codebase.

Monday, August 15, 2016

Make color transparent (Hex values of Alpha color codes)

Here's a correct table of percentages to hex values. E.g. for 50% white you'd use #80FFFFFF

Using the below values one can achieve transparency in any color.

AARRGGBB where AA represents the alpha value and can be replaced with hex values from below table to achieve desired transparency.

  • 100% — FF
  • 95% — F2
  • 90% — E6
  • 85% — D9
  • 80% — CC
  • 75% — BF
  • 70% — B3
  • 65% — A6
  • 60% — 99
  • 55% — 8C
  • 50% — 80
  • 45% — 73
  • 40% — 66
  • 35% — 59
  • 30% — 4D
  • 25% — 40
  • 20% — 33
  • 15% — 26
  • 10% — 1A
  • 5% — 0D
  • 0% — 00

Taken from SO for my future reference 

Sunday, August 14, 2016

Screen resolutions

  • 36x36 (0.75x) for low-density
  • 48x48 (1.0x baseline) for medium-density
  • 72x72 (1.5x) for high-density
  • 96x96 (2.0x) for extra-high-density
  • 144x144 (3.0x) for extra-extra-high-density
  • 192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)


In short 

mdpi
ldpi = 0.75 X mdpi
hdpi = 1.5 X mdpi
xhdpi = 2 X mdpi
xxhdpi = 3 X mdpi
xxxhdpi = 4 X mdpi

Friday, June 3, 2016

Android Studio important points


1. To Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
            File --> Other Settings --> Default settings --> Build, Execution, Deployment --> Compiler

            Command-line option takes -stacktrace option to get the stack trace.
            Run with --info or --debug option to get more log output.

2. Suggestion: add 'tools:replace="android:icon"' to <application> element in AndroidManifestAdd xmlns:tools="http://schemas.android.com/tools" to manifest tag and tools:replace="android:icon,android:theme,android:label" to application tag.

3. For the error unmappable character for encoding UTF-8.......... Add the following line to build.gradle
android {
 ...
compileOptions.encoding = 'ISO-8859-1'
 }

4. Add support library to Android Studio project

5. Open File -> Project Structure... menu.
6. Select Modules in the left pane, choose your project's main module in the middle pane and openDependencies tab in the right pane.
7. Click the plus sign in the right panel and select "Maven dependency" from the list. A Maven dependency dialog will pop up.
8. Enter "support-v4" into the search field and click the icon with magnifying glass.
9. Run the below command in terminal to detect which image file is causing the merge to fail. After running the command check for buildLog.txt file in Project window, search for Error which will point to the exact file causing the issue.
gradlew :app:mergeDebugResources --debug > buildLog.txt
10. All com.android.support libraries must use the exact same version specification
Solution : https://stackoverflow.com/a/42374426 

Saturday, May 21, 2016

Compiling POCO libraries for Android



Create a standard toolchain

http://developer.android.com/ndk/guides/standalone_toolchain.html


$NDK_ROOT/build/tools/make-standalone-toolchain.sh \
--arch=arm --platform=android-18 --toolchain=arm-linux-androideabi-4.8 --install-dir=/Users/saba/azhar/work/android/POCO/poco-android-toolchain

————————————————————————
On El-Captain Install the openssl (openssl should be already present on a linux system)

brew install openssl
brew link openssl --force


————————————————————————

POCO build complete edition with NetSSL_OpenSSL and Crypto(without ODBC and MySQL)

cd /Users/ss/aa/work/android/POCO/poco-1.6.1-all_Shared

export PATH=$PATH:/Users/ss/aa/work/android/POCO/poco-android-toolchain/bin

./configure --config=Android --no-samples --no-tests --omit=Data/ODBC,Data/MySQL --include-path=/usr/local/Cellar/openssl/1.0.2d_1/include --library-path=/usr/local/Cellar/openssl/1.0.2d_1/lib

make -s -j4
————————————————————————

POCO build basic edition 

cd /Users/ss/aa/work/android/poco-1.6.1

export PATH=$PATH:/Users/ss/aa/work/android/POCO/poco-android-toolchain/bin

./configure --config=Android --no-samples --no-tests

make -s -j4

————————————————————————

By default POCO will compile static libs (.a) files but yet I haven't been able to successfully create a JNI wrapper to use functions available in static libs. So I compiled the shared libs and used them.

To generate shared libs open the below make file
/Users/ss/aa/work/android/POCO/poco-1.6.1-all_Shared/build/config/Android 

and change from

LINKMODE           ?= STATIC

to

LINKMODE           ?= SHARED


After the complete POCO libs are built they should be available in lib folder present under Root of POCO  (poco-1.6.1-all_Shared and poco-1.6.1 in my case)

Although I could generate all static libs, I could not generate the libPocoNetSSL.so lib.
I guess it was because the openssl lib that the POCO code referes to was using a static lib on MAC and creating a shared lib using static lib was causing some problem.

I speculate that the problem should not exist on a linux machine. Will try out soon and post the results.

————————————————————————

Do a clean up of POCO

make clean
rm -f -R lib
popd

rm -f -R Platform/Android/lib

rm -f -R Platform/iOS/lib

rm -f -R Platform/MacOS/lib

rm -f -R Build/iOS

rm -f -R Build/Android

rm -f -R Build/Darwin

————————————————————————
System 

OS X El Capitan
————————————————————————


Reference : -

http://pocoproject.org/docs/99300-AndroidPlatformNotes.html 



Monday, July 20, 2015

Fetching application data

Device must be rooted

  Open cmd
  Type 'adb shell'
  su
  Press 'Allow' on device
  chmod 777 /data
  chmod 777 /data/data
  chmod 777 /data/data/com.application.package
  chmod 777 /data/data/com.application.package/*

Open DDMS view in Eclipse and from there open 'FileExplorer' to get your desired file

After this you should be able to browse the files on the device.

Thursday, June 25, 2015

Wifi debugging on eclipse for Android

Wifi debugging on eclipse for Android
Connect your phone via usb and let it detect.
Execute following commands from platform-tools/adb.
> adb tcpip 5555
this will ping your android phone
> adb connect <ipaddress_of_phone>
this will connect with your phone

On successful completion, remove usb cable and njoy debugging without usb cable.

If you wanna reconnect again your phone for debugging, just execute the second command without connecting it with usb wire.

finally
> adb disconnect