一、导入库文件
1. 拷贝以下两个文件到工程的 libs 目录下
ble_mesh-android_api_high-release.aar
ble_mesh-android_api_low-release.aar
2. 修改 app 中的 build.gradle 增加以下内容
implementation 'com.google.code.gson:gson:2.8.5' implementation(name:'ble_mesh-android_api_high-release', ext:'aar') implementation(name:'ble_mesh-android_api_low-release', ext:'aar')
3. 增加简单的代码测试工程
public class MainActivity extends AppCompatActivity {
BluetoothMesh bluetoothMesh = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
BluetoothMesh.initialize(getApplicationContext(), new BluetoothMeshConfiguration());
} catch (BluetoothMeshException e) {
e.printStackTrace();
}
bluetoothMesh = BluetoothMesh.getInstance();
try {
bluetoothMesh.createNetwork("zhcNetwork");
} catch (NetworkCreationException e) {
e.printStackTrace();
}
}
}
二、运行报错解决
修改 app 中的 build.gradle 增加以下内容:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.31"