Androidアプリとマイコン間でBluetooth通信を行いたい
https://www.hiramine.com/programming/bluetoothcommunicator/02_scan_device.html
上記のサイトをまねしてアプリとマイコンでBluetooth通信を行いたいと考えています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
ビルドは通るのですが、アプリ上でBluetoothデバイス検索ボタンをタップするとアプリが強制的に終了されてしまう。
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.bluetoothcommunicator02, PID: 23648 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bluetoothcommunicator02/com.example.bluetoothcommunicator02.DeviceListActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2675) at android.app.ActivityThread.access$900(ActivityThread.java:195) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:210) at android.app.ActivityThread.main(ActivityThread.java:5943) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:817) Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout at android.view.LayoutInflater.inflate(LayoutInflater.java:561) at android.view.LayoutInflater.inflate(LayoutInflater.java:437) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.bluetoothcommunicator02.DeviceListActivity.onCreate(DeviceListActivity.java:170) at android.app.Activity.performCreate(Activity.java:6405) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2562) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2675) at android.app.ActivityThread.access$900(ActivityThread.java:195) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:210) at android.app.ActivityThread.main(ActivityThread.java:5943) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:817) Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:803) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:731) at android.view.LayoutInflater.inflate(LayoutInflater.java:514) at android.view.LayoutInflater.inflate(LayoutInflater.java:437) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.bluetoothcommunicator02.DeviceListActivity.onCreate(DeviceListActivity.java:170) at android.app.Activity.performCreate(Activity.java:6405) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2562) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2675) at android.app.ActivityThread.access$900(ActivityThread.java:195) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:210) at android.app.ActivityThread.main(ActivityThread.java:5943) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:817) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.example.bluetoothcommunicator02-2/base.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.bluetoothcommunicator02-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.bluetoothcommunicator02-2/lib/arm, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at android.view.LayoutInflater.createView(LayoutInflater.java:605) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:791) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:731) at android.view.LayoutInflater.inflate(LayoutInflater.java:514) at android.view.LayoutInflater.inflate(LayoutInflater.java:437) at android.view.LayoutInflater.inflate(LayoutInflater.java:380) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.example.bluetoothcommunicator02.DeviceListActivity.onCreate(DeviceListActivity.java:170) at android.app.Activity.performCreate(Activity.java:6405) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2562) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2675) at android.app.ActivityThread.access$900(ActivityThread.java:195) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1515) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:210) at android.app.ActivityThread.main(ActivityThread.java:5943) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:956) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:817) Suppressed: java.lang.ClassNotFoundException: android.support.constraint.ConstraintLayout at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass
該当のソースコード
https://www.hiramine.com/programming/bluetoothcommunicator/02_scan_device.html
試したこと
ここに問題に対して試したことを記載してください。
補足情報
コピー&ペーストコードを入力しAlt+Enterでインポートを追加していきました。
しかし、import android.support.v7.app.AppCompatActivity;は追加されませんでした。
なぜなのでしょうか?
回答1件
あなたの回答
tips
プレビュー