react-native 调用第三方 SDK

步骤一:android 文件修改

(1)In android/settings.gradle

...
include ':VoiceModule', ':app'
project(':VoiceModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-voice')

react-native 调用第三方 SDK

(2)In android/app/build.gradle

...
dependencies {
...
compile project(':VoiceModule')
}

react-native 调用第三方 SDK

(3)Register Module (In android/app/src/main/java/com/reactnative/MainApplication.java)

import com.wmjmc.reactspeech.VoicePackage;  // <--- import

public class MainApplication extends Application implements ReactApplication {
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VoicePackage() // <--- added here
);
}
}

react-native 调用第三方 SDK

react-native 调用第三方 SDK

(4)修改包文件 同步版本

react-native 调用第三方 SDK

(5)调用

import Tts from 'react-native-tts';

Tts.getInitStatus().then(() => {
Tts.speak('Hello, world!');
});

.

上一篇:git实战中遇到git@github.com: Permission denied (publickey).的问题


下一篇:mysql 开发进阶篇系列 45 物理备份与恢复(xtrabackup 安装,用户权限,配置)