Android app發佈到GooglePlay
開頭的廢話: 最近使用cocoscreator開發的一個遊戲的android版本需要發佈到google play, 要上傳到google play就需要再app中集成google play service, 以前本來接入過,接入過程非常簡單,也有發佈到google play的應用,結果時間長了居然給忘掉了,google了一下才配置好,所以索性將它記錄下來,以免再忘
本文使用的是AndroidStudio的工程進行開發,文章也只是大致講述在發佈到googleplay上,程序配置上需要進行的工作
1. 配置build.gradle
在app level下的build.gradle文件中加入google play service的依賴,不配置的話步驟2中的google_play_services_version就找不到定義
dependencies {
implementation 'com.google.android.gms:play-services:12.0.1'
}
2. 配置AndroidManifest.xml
<!-- google play -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
google_play_services_version不需要自己定義,它由google play service定義,它的值也隨着google play service的版本變化而變化
上傳apk至google play 必須加入這個配置,否則不能成功上傳
配置到這裏,就已經能夠上傳到google play了
3.跳轉至GooglePlay商店
app一般都有個引導評論的功能,android的app一般直接跳轉到GooglePlay商店詳情頁面,用戶可以在這裏給app打分和評論,附上代碼
public static void launchAppDetail() {
final String GOOGLE_PLAY = "com.android.vending";//這裏對應的是谷歌商店,跳轉別的商店改成對應的即可
try {
Uri uri = Uri.parse("market://details?id=" + mActivity.getPackageName());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage(GOOGLE_PLAY);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mActivity.startActivity(intent);
} catch (Exception e) {
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(mActivity, "GooglePlay Store not exist", Toast.LENGTH_SHORT).show();
}
});
}
}