Google App Invite - 启动失败
Google App Invite - Failed to start
我正在尝试按照其官方 documentation and latest configuration on GitHub.
中的所有步骤在我的项目中使用 Google App Invite
但是,它在调试版和发布版中根本不起作用!它只在两个版本中显示此 Snackbar
消息:
Failed to start
它不会在调试模式下留下任何堆栈跟踪,我已经尝试使用我的 Google 开发者帐户的 Alpha 测试安装它的发布版本。这是我在 release 版本上的完整项目配置:
Android Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.name">
<application
... >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
...
</manifest>
项目级 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
classpath 'com.google.gms:google-services:2.0.0-beta6'
// I've tried classpath 'com.google.gms:google-services:2.0.0-alpha5' too
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...
应用程序级 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
}
...
dependencies {
...
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
代码
Intent inviteIntent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
.setMessage(getString(R.string.invitation_message))
.setDeepLink(Uri.parse(getString(R.string.invitation_deep_link)))
.setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
.setCallToActionText(getString(R.string.invitation_cta))
.build();
startActivity(inviteIntent);
我还添加了来自 Google Developers Console 的配置文件到我项目的 app/ 目录,其中包括包名称和来自发布密钥的 SHA-1 .
有什么解决办法吗?
我不使用 classpath 'com.google.gms:google-services:2.0.0-beta6'
,只使用 compile 'com.google.android.gms:play-services-appinvite:8.4.0'
对我有用。
我的意图:
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.appinvite_title))
.setMessage(getString(R.string.appinvite_message))
.setDeepLink(Uri.parse(getString(R.string.appinvites_deep_link)))
.build();
startActivityForResult(intent, REQUEST_INVITE);
这与您的差别不大。你编码你的 DeepLinkBroadcastReceiver
和你的 DeepLinkActivity
了吗?
我终于自己找到了答案。实际上,使用 startActivityForResult(intent, requestCode);
是 REQUIRED 而不是仅 startActivity(intent);
才能使其正常工作。我不明白为什么它是强制性的,因为一些开发人员(比如我自己)不需要回调操作 IMO。
我正在尝试按照其官方 documentation and latest configuration on GitHub.
中的所有步骤在我的项目中使用 Google App Invite但是,它在调试版和发布版中根本不起作用!它只在两个版本中显示此 Snackbar
消息:
Failed to start
它不会在调试模式下留下任何堆栈跟踪,我已经尝试使用我的 Google 开发者帐户的 Alpha 测试安装它的发布版本。这是我在 release 版本上的完整项目配置:
Android Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.name">
<application
... >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
...
</manifest>
项目级 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
classpath 'com.google.gms:google-services:2.0.0-beta6'
// I've tried classpath 'com.google.gms:google-services:2.0.0-alpha5' too
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...
应用程序级 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.package.name"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
}
...
dependencies {
...
compile 'com.google.android.gms:play-services-appinvite:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
代码
Intent inviteIntent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title))
.setMessage(getString(R.string.invitation_message))
.setDeepLink(Uri.parse(getString(R.string.invitation_deep_link)))
.setCustomImage(Uri.parse(getString(R.string.invitation_custom_image)))
.setCallToActionText(getString(R.string.invitation_cta))
.build();
startActivity(inviteIntent);
我还添加了来自 Google Developers Console 的配置文件到我项目的 app/ 目录,其中包括包名称和来自发布密钥的 SHA-1 .
有什么解决办法吗?
我不使用 classpath 'com.google.gms:google-services:2.0.0-beta6'
,只使用 compile 'com.google.android.gms:play-services-appinvite:8.4.0'
对我有用。
我的意图:
Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.appinvite_title))
.setMessage(getString(R.string.appinvite_message))
.setDeepLink(Uri.parse(getString(R.string.appinvites_deep_link)))
.build();
startActivityForResult(intent, REQUEST_INVITE);
这与您的差别不大。你编码你的 DeepLinkBroadcastReceiver
和你的 DeepLinkActivity
了吗?
我终于自己找到了答案。实际上,使用 startActivityForResult(intent, requestCode);
是 REQUIRED 而不是仅 startActivity(intent);
才能使其正常工作。我不明白为什么它是强制性的,因为一些开发人员(比如我自己)不需要回调操作 IMO。