我使用了一些使用RXTX库的库,但是android似乎无法使用它。
我正在使用树莓派,并尝试为Adafruit库Fona启动Uart
Fona fona = new Fona();
try {
fona.open("UART0", 115200);
} catch (FonaException e) {
e.printStackTrace();
}
try {
fona.smsSend("0555555555", "Hello from FONA!");
} catch (FonaException e) {
e.printStackTrace();
}
try {
fona.close();
} catch (FonaException e) {
e.printStackTrace();
}
但是我收到以下错误
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/com.google.android.things.jar"
这是我授予USE_PERIPHERAL_IO权限的清单
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.things.permission.SET_TIME" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.things.permission.USE_PERIPHERAL_IO" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.bluetooth_le" />
<application>
<uses-library android:name="com.google.android.things" />
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Start automatically after boot and re-start if the app is terminated. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
和我添加了android库的gradle
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.www.fun"
minSdkVersion 27
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
compileOnly 'com.google.android.things:androidthings:1.0'
implementation 'com.google.firebase:firebase-core:11.6.0'
implementation('com.google.firebase:firebase-database:11.6.0') {
exclude module: 'support-v4'
}
implementation('com.google.firebase:firebase-auth:11.6.0') {
exclude module: 'support-v4'
}
implementation files('libs/xbee-java-library-1.2.1.jar')
implementation files('libs/RXTXcomm-2.2pre2.jar')
}
dependencies {
implementation ('com.google.android.things:cloud-iot-core:1.0.0'){
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'
最后,我将OS版本1.0.3用于构建。
反正我可以在那里工作吗