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就找不到定义
?
1 2 3 | dependencies { implementation 'com.google.android.gms:play-services:12.0.1' } |
2. 配置AndroidManifest.xml
?
1 2 | <!-- google play --> <meta-data android:name= "com.google.android.gms.version" android:value= "@integer/google_play_services_version" ></meta-data> |
google_play_services_version不需要自己定义,它由google play service定义,它的值也随着google play service的版本变化而变化
上传apk至google play 必须加入这个配置,否则不能成功上传
配置到这里,就已经能够上传到google play了
3.跳转至GooglePlay商店
app一般都有个引导评论的功能,android的app一般直接跳转到GooglePlay商店详情页面,用户可以在这里给app打分和评论,附上代码
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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(); } }); } } |
https://www.2cto.com/kf/201807/759762.html