3

我正在尝试按照其官方文档和GitHub 上的最新配置中的所有步骤在我的项目中使用 Google App Invite 。

但是,它在调试和发布版本中都不起作用!它仅Snackbar在两个版本中显示此消息:

未能启动

它不会在调试模式下留下任何堆栈跟踪,我已经通过使用我的 Google 开发者帐户中的 Alpha 测试安装它来尝试发布版本。这是我在发布版本上的完整项目配置:

安卓清单.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。

有什么解决办法吗?

4

2 回答 2

5

我终于自己找到了答案。实际上,使用startActivityForResult(intent, requestCode);必需的,而不仅仅是startActivity(intent);让它工作。我不明白为什么它是强制性的,因为一些开发人员(比如我自己)不需要回调操作 IMO。

于 2016-03-14T16:28:59.543 回答
2

我不使用classpath 'com.google.gms:google-services:2.0.0-beta6'using justcompile '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吗?

于 2016-03-11T17:05:16.943 回答