前提・実現したいこと
I want to create a biometric plugin in AndroidStudio and connect it with Unity to check it on the actual device.
AndroidStudioで生体認証プラグインを作成し、Unityと接続して実機で確認したいと考えています。
I want to solve the error and make biometric authentication work on the actual device.
このエラーを解決して、実機で生体認証を動作させたい。
I've added the missing libraries and other research as far as I can tell, but I can't figure it out, so please help me out!
足りていないライブラリ等自分がわかる範囲で調査追加しましたが、調べてもわからないのでお力をお貸しください
発生している問題・エラーメッセージ
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/app/AppCompatActivity java.lang.ClassNotFoundException: androidx.appcompat.app.AppCompatActivity
該当のソースコード
gradle
1plugins { 2 id 'com.android.library' 3} 4 5android { 6 compileSdkVersion 31 7 8 defaultConfig { 9 minSdkVersion 16 10 targetSdkVersion 30 11 versionCode 1 12 versionName "1.0" 13 14 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 consumerProguardFiles "consumer-rules.pro" 16 } 17 18 buildTypes { 19 release { 20 minifyEnabled false 21 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 } 23 } 24 compileOptions { 25 sourceCompatibility JavaVersion.VERSION_1_8 26 targetCompatibility JavaVersion.VERSION_1_8 27 } 28} 29 30dependencies { 31 implementation 'androidx.appcompat:appcompat:1.3.0' 32 implementation 'com.google.android.material:material:1.3.0' 33 implementation 'androidx.biometric:biometric:1.1.0' 34 35 implementation "androidx.activity:activity:1.2.3" 36 testImplementation 'junit:junit:4.+' 37 androidTestImplementation 'androidx.test.ext:junit:1.1.3' 38 androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 39}
java
1package com.example.biometricslibs; 2 3import android.content.Context; 4import androidx.appcompat.app.AppCompatActivity; 5import androidx.annotation.NonNull; 6import androidx.biometric.BiometricPrompt; 7import androidx.core.content.ContextCompat; 8import java.util.concurrent.Executor; 9 10public class MainActivity extends AppCompatActivity{ 11 public static MainActivity instance() { 12 return new MainActivity(); 13 } 14 15 private BiometricPrompt biometricPrompt; 16 17 private BiometricPrompt.AuthenticationCallback callback = new BiometricPrompt.AuthenticationCallback() { 18 @Override 19 public void onAuthenticationError(int errorCode, @NonNull CharSequence errString) { 20 super.onAuthenticationError(errorCode, errString); 21 if (errorCode == 13 && biometricPrompt != null) 22 biometricPrompt.cancelAuthentication(); 23 } 24 25 @Override 26 public void onAuthenticationSucceeded(@NonNull BiometricPrompt.AuthenticationResult result) { 27 super.onAuthenticationSucceeded(result); 28 } 29 30 @Override 31 public void onAuthenticationFailed() { 32 super.onAuthenticationFailed(); 33 } 34 }; 35 36 public void BiometricCheck(Context context) { 37 BiometricPrompt.PromptInfo promptInfo = new BiometricPrompt.PromptInfo.Builder() 38 .setTitle("title") 39 .setSubtitle("subTitle") 40 .setDescription("description") 41 .setNegativeButtonText("cancel") 42 .build(); 43 44 Executor executor = ContextCompat.getMainExecutor(context); 45 biometricPrompt = new BiometricPrompt((AppCompatActivity)context, executor, callback); 46 47 biometricPrompt.authenticate(promptInfo); 48 } 49}
C#
1using(var nativeDialog = new AndroidJavaClass("com.example.biometricslibs.MainActivity")) 2{ 3 using(var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) 4 { 5 using(var currentUnityActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) 6 { 7 using(var instance = nativeDialog.CallStatic<AndroidJavaObject>("instance")) 8 { 9 instance.Call( 10 "BiometricCheck", 11 currentUnityActivity 12 ); 13 } 14 } 15 } 16}
補足情報(FW/ツールのバージョンなど)
Unity2019.2.21f1
Android Studio Arctic Fox | 2020.3.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。