Reference

No static method metafactory()

If this:

java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.art/javalib/core-oj.jar)

Do this:

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

Reference

Android Certificate Pinning

Convert .cer to .crt

openssl x509 -inform DER -in <certificate>.cer -out <certificate>.crt 

Generate the SHA256 hash:
openssl x509 -pubkey < <certificate>.crt | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | base64

You get your base64 hash pin

Reference

AndroidStudio certificate path

Adding a trusted cert to your cacerts keystore. Helps if you see an error that looks like this when trying to download some 3rd party dependencies for Android dev Unable to find valid certification path to requested target

  1. Download KeyStore Explorer https://keystore-explorer.org/downloads.html
  2. Use KeyStore Explorer to open cacerts in the jre your AndroidStudio is configured to use. I’m using the packaged instance so I’m looking in /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/jre/lib/securityThe password for this is “changeit
  3.  Go to the offending host (bintray.com, jitpack.io, etc…) and export the cert.
  4. Back in Keystore Explorer tlick the “Import Trusted Certificate” icon and find the cert you just exported.
  5. Save the cacerts keystore and restart Android.

Reference

Viewing an Android app sqlite db

Need to have a look at a sqlite DB in an android app. Need to grab this first.

Then do the backup (This is currently deprecated, so probably won’t be around forever, but works for now)

adb backup [your.app.package.name]  

Check the phone and allow the backup

java -jar abe.jar unpack backup.ab backup.tar ""

Creates a zip where you can find the db. Open it with your favorite db app.

There’s also this:

adb -d shell "run-as [your.app.package.name] cat /data/data/your.app.package.name/databases/[your_database.db] > /sdcard/filename.sqlite"

adb pull /sdcard/filename.sqlite

But all I get is an empty filename.sqlite file. May need to make it work if/when the above is removed.