Gradle Dependency バージョンのチェックを「最新」に更新する方法

便利そうなのでました!

Android Developers Blog: Announcing new SDK versioning in Google Play services and Firebase

com.google.android.gms:play-services-*
com.google.firebase:firebase-*

に関しては、それぞれが独立したバージョンで記述してよい。

なので、以下のような「バージョンをを揃える」記述は不要。


buildscript {
    ext {
        play_version = '15.0.0'
    }
}

dependencies {
    // DON'T DO THIS!!
    // The following use of the above buildscript property is no longer valid.
    implementation "com.google.android.gms:play-services-auth:${play_version}"
    implementation "com.google.firebase:firebase-auth:${play_version}"
    implementation "com.google.firebase:firebase-firestore:${play_version}"
}

利用方法は以下2パターン。


classpath 'com.google.gms:google-services:3.3.0'

// 最終行
apply plugin: 'com.google.gms.google-services' 

かまたは、


classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.0'

// 最終行
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

とのこと。

 

やってみたが...

エラー。

ビルドできず。


The library com.google.android.gms:play-services-measurement-base
is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]],
but resolves to 15.0.2. Disable the plugin and check your dependencies tree
using ./gradlew :app:dependencies.

記述にはない「play-services-measurement-base」が

内部的に呼ばれてこけている。

メッセージに書いてある


./gradlew :app:dependencies

は実行すらできない。

それぞれは、Andrid Studioの自動チェックで最新のはずなのだが。

 

それぞれのバージョンを確認してみる

目視でGoogleリポジトリを確認。

Google's Maven Repository

AndroidStudioの自動チェックで最新版の「15.0.0」だと思っていたが

実は、古いバージョンのままだった。

実際は「15.0.2」が最新。

これに書き換えたらいけた。

しかし、AndroidStudioの自動最新バージョンチェック機能らしきは、

機能してなくね?

かまたは、微妙に古くね?

 

Lint「Newer Library Versions Available」 を確認する

「Preference」-「Editor」-「Inspections」 にある

「Lint」-「Newer Library Versions Available」

OFFになってるが。

Description
Newer Library Versions Available This detector checks with a central repository to see if there are newer versions available for the dependencies used by this project. This is similar to the GradleDependency check, which checks for newer versions available in the Android SDK tools and libraries, but this works with any MavenCentral dependency, and connects to the library every time, which makes it more flexible but also much slower.

「毎回チェックするのでとろい」ということで

デフォルトでOFFになっているのか。

毎回でなく適時、意図的に実行したい場合は、

「Analyze」-「Run Inspection by Name」からいきましょう。

 

グレーのハイライトと同時にツールチップで最新版である

「15.0.2」

をサジェストしてくれました!

【Android Studio】ビルド環境を安定した最新バージョンにする


Play Services 12.0.0 で android.permission.READ_PHONE_STATE が要求されている件

Google Play Console にアップすると怒られて受け付けてくれません。

"New permissions added
WARNING
Users that have the APK with version code 19 may need to accept one or more of the android.permission.READ_PHONE_STATE and android.permission.WRITE_EXTERNAL_STORAGE permissions, which may result in them not upgrading to this version of the app."

android.permission.READ_PHONE_STATE てどんな許可内容だったか。

端末のステータスとIDの読み取り
端末の電話機能へのアクセスをアプリに許可します。これにより、電話番号、端末ID、通話中かどうか、通話相手の電話番号をアプリから特定できるようになります。

危険なパーミッションです。

「通話機能の必要ないアプリでも Play Service を利用していれば弾かれる」というような状況のようです。

android.permission.READ_PHONE_STATE added with Play Services 12.0.0 [76024034] - Visible to Public - Issue Tracker

android - Why has the READ_PHONE_STATE permission been added? - Stack Overflow

以下で回避できるようです。できました。


<uses-permission
    android:name="android.permission.READ_PHONE_STATE"
    tools:node="remove" />

なんなんでしょうね。

このような混乱はきっとこの先も増えていきそうです。

ーーー
2018-04-04: 追記
修正されているようです。
Release Notes  |  Google APIs for Android  |  Google Developers


【仮想通貨】Cryptowatch Public Market REST API を眺める

キャバ嬢に

「リップル買っちゃった。名前がかわいいし。」

などと言われて即全てを手放しました、おはようございます。

そんな下落が止まらない仮想通貨たち。

仮想通貨全体の上げ下げを把握することができます。

Cryptowatch - live Bitcoin price charts

ここではAPIにてリアルタイムな情報を公開しています。

無料では当然制限はついてきますが。

Public Market REST API - Cryptowatch

いくつか簡単にデータを取得してみましょう。

Prices

Returns the current price for all supported markets. Some values may be out of date by a few seconds.

Example: https://api.cryptowat.ch/markets/prices

価格です。量が多いので日本円絡みのものだけ見てみます。


~ $ curl -s https://api.cryptowat.ch/markets/prices | jq "." | grep jpy
    "bitflyer:btcfxjpy": 990450,
    "bitflyer:btcjpy": 980519,
    "bitflyer:btcjpy-biweekly-futures": 984440,
    "bitflyer:btcjpy-weekly-futures": 984750,
    "bitmex:btcjpy-quarterly-futures": 9342,
    "kraken:btcjpy": 980085,
    "kraken:ethjpy": 102171,
    "kraken:repjpy": 0,
    "kraken:xrpjpy": 0,
    "kraken:zecjpy": 0,
    "quoine:bchjpy": 139770.97,
    "quoine:btcjpy": 1010138.75,
    "quoine:ethjpy": 107000,

いくつかは価格が「0」となっていますが。

JSON形式で、項目としては


"(取引所):(通貨ペア)": 価格円

が取得できるようです。

もうひとつみてみます。

Asset
Returns a single asset. Lists all markets which have this asset as a base or quote.

Example: https://api.cryptowat.ch/assets/btc

こちらでは以下のようなものが取得できます。


~ $ curl -s https://api.cryptowat.ch/assets/jpy | jq '.'
{
  "result": {
    "id": 104,
    "symbol": "jpy",
    "name": "Japanese Yen",
    "fiat": true,
    "markets": {
      "quote": [
        {
          "id": 89,
          "exchange": "kraken",
          "pair": "btcjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/kraken/btcjpy"
        },
        {
          "id": 100,
          "exchange": "kraken",
          "pair": "ethjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/kraken/ethjpy"
        },
        {
          "id": 120,
          "exchange": "kraken",
          "pair": "repjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/kraken/repjpy"
        },
        {
          "id": 126,
          "exchange": "kraken",
          "pair": "zecjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/kraken/zecjpy"
        },
        {
          "id": 140,
          "exchange": "kraken",
          "pair": "xrpjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/kraken/xrpjpy"
        },
        {
          "id": 184,
          "exchange": "quoine",
          "pair": "btcjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/quoine/btcjpy"
        },
        {
          "id": 196,
          "exchange": "quoine",
          "pair": "ethjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/quoine/ethjpy"
        },
        {
          "id": 206,
          "exchange": "quoine",
          "pair": "bchjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/quoine/bchjpy"
        },
        {
          "id": 215,
          "exchange": "bitflyer",
          "pair": "btcjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/bitflyer/btcjpy"
        },
        {
          "id": 217,
          "exchange": "bitflyer",
          "pair": "btcjpy-weekly-futures",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/bitflyer/btcjpy-weekly-futures"
        },
        {
          "id": 218,
          "exchange": "bitflyer",
          "pair": "btcjpy-biweekly-futures",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/bitflyer/btcjpy-biweekly-futures"
        },
        {
          "id": 409,
          "exchange": "bitflyer",
          "pair": "btcfxjpy",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/bitflyer/btcfxjpy"
        },
        {
          "id": 248,
          "exchange": "bitmex",
          "pair": "btcjpy-quarterly-futures",
          "active": true,
          "route": "https://api.cryptowat.ch/markets/bitmex/btcjpy-quarterly-futures"
        },
        {
          "id": 424,
          "exchange": "bitmex",
          "pair": "btcjpy-monthly-futures",
          "active": false,
          "route": "https://api.cryptowat.ch/markets/bitmex/btcjpy-monthly-futures"
        }
      ]
    }
  },
  "allowance": {
    "cost": 162263,
    "remaining": 7999837737
  }
}

これを見ると個別のチャートを参照できるURLは


https://api.cryptowat.ch/markets/(取引所)/(通貨ペア)

であることがわかります。

他にもたくさんのデータが取得できるようです。

さあ、みんなもやってみよう。

 

👉 Kotlin 今どきよくある JSON リクエストからのパース hatena-bookmark