Skip to content

Instantly share code, notes, and snippets.

@ryu1
Last active May 8, 2019 08:19
Show Gist options
  • Select an option

  • Save ryu1/c16e814b078d25a001aefe9c6aae8e04 to your computer and use it in GitHub Desktop.

Select an option

Save ryu1/c16e814b078d25a001aefe9c6aae8e04 to your computer and use it in GitHub Desktop.
Android Tips

Android Tips

ADBの起動/停止

adbの停止

$ adb kill-server

adbを起動

$ adb start-server

コマンドラインからIntentをbroadcastする

外部電源に接続

$ adb root
$ adb shell am broadcast -a android.intent.action.ACTION_POWER_CONNECTED -p <Package Name>

WiFiリモートデバッグ

  1. Android端末をPCにUSB接続する.

  2. Android端末とPCを同一ネットワークに接続する.

  3. 以下のコマンドを実行する.

    $ adb tcpip 5555
    $ adb connect 192.168.1.10 # Android端末のIPアドレス
    
  4. Android Studioから通常通りRunする.

APKを端末にインストールする

コマンドライン

$ adb install -r ./PathTo.apk

端末のアプリ領域に入る

$ adb shell
$ pm list packages | grep "package name filtered"
$ run-as "package name"

ビルド時に非推奨APIの警告が表示する

build.gradle

android {

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment