JG Web Designs - Aurora, IL website design, development, SEO, SMM
delivering simple, effective website solutions
630-674-9763
[email protected]
  • Home
  • About
    • What's new
    • Contact
  • Portfolio
    • Testimonials
  • Business
    • Social Media Marketing
    • Lifecycle
  • Programming Services
    • Android development tips and tricks

Code optimization in Android Studio 3.4 and beyond

1/17/2020

0 Comments

 
If you have an Android app project that may have worked previously and you've recently migrated Android Studio to version 3.4 or later, check you dependencies and then check your proguard-rules.pro file if you are using one.

I recently ran into a situation using the DFU library from Nordic Semiconductor where downloading code to phones and then doing DFU of Nordic based BLE devices worked swimmingly.  I then built a release version and.....kablooie!  DFU File Error failure.

Turned out I needed the following in my proguard-rules.pro file:

-keep class no.nordicsemi.android.dfu.** { *; }

Generally, if you think you're having an issue with code in a given package, you might need

-keep class <package-name>.** { *; }

in your proguard-rules.pro file to prevent the new R8 compiler (replaces ProGuard now) from optimizing something you actually need.

See Android developer docs for more details:  
https://developer.android.com/studio/build/shrink-code#usage
​

0 Comments

Disable USB port

7/3/2015

3 Comments

 
Possible solution to disable USB port if your device has one and you need security...Find the device file for your port, mine is shown below, and run the following 2 commands

#cd /sys/devices/platform/fsl-ehci.0/usb1/
#echo 0 > authorized


To ENABLE the USB port...
#cd /sys/devices/platform/fsl-ehci.0/usb1/

#echo 1 > authorized 


appears to successfully toggle it back ON/Enabled...also, disabling USB access by the method above appears to NOT persist through a reboot so this likely would need to be part of a script run by your app or part of your app if you need to maintain a disabled port for the sake of security

USB Disable/Enable method described here also appears to work on USB mass storage (thumb drive) - i.e. when disabled, the "udisk" folder shows up empty in ESFileExplorer

This has only been proven in concept by trying from a shell session.

3 Comments

Hiding the Android system UI

7/2/2015

1 Comment

 
To hide/show the UI from with your app...
After a lot of searching on the internet, I managed to get the System Bar to hide and appear in a 4.2 device using the commands below
To Hide:

Runtime.getRuntime().exec("service call activity 42 s16 com.android.systemui");
Or use 79 instead of 42 for API less than 14.

To Show:

Runtime.getRuntime().exec("am startservice --user 0 -n com.android.systemui/.SystemUIService");


1 Comment

Extracting manifest info from an APK file

7/2/2015

7 Comments

 
If you ever need to extract information from a APK's manifest file (e.g. to get the name of the launch activity),

You can use Android application packaging tool (AAPT) found under the build-tools folder under your Android SDK installation

$ aapt dump --values xmltree <name>.apk AndroidManifest.xml

and then you have to parse the output to find needed info. The output is a little "rough" but usable.

The parts in bold above are fixed/required.  The "<name>.apk" is the name of the APK file from which you're extracting the manifest.

You probably want to redirect the output to a local file to have for future reference, since the line above just outputs to the screen.  So...for example

C:\Eclipse_ADT\adt-bundle-windows-x86_64-20140702\sdk\build-tools\17.0.0> aapt dump --values xmltree <app-name>.apk AndroidManifest.xml > C:\temp\app-name_Manifest.txt


7 Comments

Background

7/2/2015

1 Comment

 
Picture
Unless stated otherwise, everything discussed herein is related to development I've done on semi custom hardware, (Freescale-based, derived from a FS reference platform) with a rooted BSP/OS (also based on a Freescale reference build).  I have not built the BSP (nor have I ever built a BSP)
1 Comment
    Picture

    Unless stated otherwise, everything discussed herein is related to development I've done on semi custom hardware, (Freescale-based, derived from a FS reference platform) with a rooted BSP/OS (also based on a Freescale reference build).  I have not built the BSP (nor have I ever built a BSP)

    Author

    John Goluch has been a software developer since 1989. He has developed code for a variety of embedded systems in Assembly and C, for the web in HTML/JS/PHP, and mobile devices in Qt/C++ and Android/Java.  Content here comes from "in the weeds" level of research and discovery related to Android development

    Archives

    January 2020
    July 2015

    Categories

    All

    RSS Feed

JG Web Designs | Aurora, IL 60504 | 630.674.9763 | [email protected]