79°

亚马逊语义服务demo运行

1、下载官方demo

https://github.com/willblaschko/AlexaAndroid

2、导入Android studio后,注释掉app/build.gradle中signing.gradle的部分,因为demo中没有签名脚本

使用自己的签名,生成签名文件,在app/build.gradle中配置,如下所示

apply plugin: 'com.android.application'


//if (file('signing.gradle').exists()) {
//    apply from: 'signing.gradle'
//}else{
//    throw new TaskExecutionException(null, new Exception("Unable to find signing.gradle, please replace Android buildTypes > signing configs with your own configuration."));
//}

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.willblaschko.android.alexavoicelibrary"
        minSdkVersion 21

        targetSdkVersion 24
        versionCode 5
        versionName "2.1.1"
        multiDexEnabled true;
    }

    signingConfigs {
        main {
            storeFile file("../demokey.jks") //签名文件路径
            storePassword "123456"
            keyAlias "key0"
            keyPassword "123456"
        }
    }
    buildTypes {
        debug{
            versionNameSuffix " Debug"
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.main
//            signingConfig signingConfigs.releaseConfig
        }
        release {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.main
//            signingConfig signingConfigs.releaseConfig
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:multidex:1.0.1'

    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile project(path: ':libs:AlexaAndroid')
    compile project(path: ':libs:RecorderLevelView')
    compile project(path: ':libs:speechutils-master')

}

3、查看自己签名的md2,sha256配置在 开发者后台的设置里,并将api密钥拷贝在/assets/api_key.txt中,这里需要注意的是api密钥每次查看都会改变,查看了就要更新到文件中,没事别查看

https://developer.amazon.com/home.html

本文由【安卓工程师王恒】发布于开源中国,原文链接:https://my.oschina.net/wfy94/blog/3029860

全部评论: 0

    我有话说: