Android 讯飞开放平台 语音听写

 

一https://www.xfyun.cn/  讯飞开放平台  下载语音听写SDK

 

二.导入 语音听写demo

2.1.speechDemo 导jar包 

2.2.AndroidManifest.xml  Manifest中添加权限

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.iflytek.voicedemo"
    android:versionCode="1"
    android:versionName="2.0.1018.1013">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

2.3. build.gradle  

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.iflytek.voicedemo"
        minSdkVersion 22
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation files('libs\\Msc.jar')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

2.4. gradle.properties

android.injected.testOnly=false

使用AS自动运行时会在app\build\outputs\apk\debug文件夹下自动生成测试APK:app-debug.apk,

用命令adb install app-debug.apk时报错:Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

解决办法:

1. 添加-t参数: 输入命令adb install -t app-debug.apk

2. 在gradle.properties(项目根目录或者gradle全局配置目录 ~/.gradle/)文件中添加:

android.injected.testOnly=false
产生原因:

Android Studio 3.0会在debug apk的manifest文件application标签里自动添加 android:testOnly="true"属性

  

  

 

posted @ 2021-09-09 10:23  CrushGirl  阅读(253)  评论(0编辑  收藏  举报