0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

開発と本番で叩くAPIURLを変えたい

Posted at

初めに

今回は、よくある開発と本番で叩くAPIのエンドポイントを変更したいときの備忘録を残しておきたいと思います

本文

まず、endpointをどこに置くか問題ですが、これは一般的にbuild.gradleに書かれることが多いので、今回はそれを前提に書いていこうと思います。

buildTypes {
        debug {
            buildConfigField(
                    "String",
                    "API_ENDPOINT",
                    "\"https://api_endpoint/\""
            )
        }
        release {
            buildConfigField(
                    "String",
                    "API_ENDPOINT",
                    "\"https://api_endpoint/\""
            )
        }
    }

最後に

実はすごく単純ですね。
これを使えばエンドポイントだけでなくストアIDなどを個別に設定することもできます。
次回の記事では開発環境の種類によって分ける方法を書いていこうと思います。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?