Closed jdivock-stripe closed 2 years ago
@jdivock-stripe did you run expo prebuild
as is described here?
Next, rebuild your app as described in the Adding custom native code guide.
Ah, okay expo run:android
doesn't complete for me due to some fun minSDK and dep issues (that I don't think are terminal SDK related). Let me work through those and see if I can resolve.
For the papertrail, this is what I hit
> Task :app:checkDebugAarMetadata FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.room:room-runtime:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/7c02cc5130a39c43a058b93c139823c3/transformed/room-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/2c90983ea39a71e4ed28953f0bc2e2f8/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/40d8c69720f4a4e15ca803802e7852dd/transformed/lifecycle-livedata-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-process:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/2c63e08ad52ed05d2de70ae87b56f471/transformed/jetified-lifecycle-process-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/96a6fc2a6feb38f2bb5bdc9211883217/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core-ktx:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/5ac3db7a49aa4b085dd5211442fe1ddd/transformed/jetified-lifecycle-livedata-core-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/9bf0b36737bb24aabba1fc2d4c0566af/transformed/lifecycle-livedata-core-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.sqlite:sqlite-framework:2.2.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/f216fbfc86c0ee20eb02ba17f4047c4f/transformed/sqlite-framework-2.2.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.sqlite:sqlite:2.2.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/ea7f145a1745e02f67969c1f56135568/transformed/sqlite-2.2.0/META-INF/com/android/build/gradle/aar-metadata.properties.
Updating minSDK results in mochi errors of a different shape:
> Task :app:checkDebugDuplicateClasses FAILED
w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: /Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar.
> Failed to transform '/Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
cc @dhenry-stripe for any gradle wizardry he may have here…
Okay, looks like this does blame back to our SDK. Here are the steps I took:
expo init jay-scratch-app
expo run:android
… which failed with https://gist.github.com/jdivock-stripe/63a6a163d7be00003e43d33bba7dcad2expo run:android
after which brought up the example app in the simulator no problemapp.json
expo run:android
, failedw: Detected multiple Kotlin daemon sessions at build/kotlin/sessions
FAILURE: Build completed with 5 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.room:room-runtime:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/7c02cc5130a39c43a058b93c139823c3/transformed/room-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/2c90983ea39a71e4ed28953f0bc2e2f8/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/40d8c69720f4a4e15ca803802e7852dd/transformed/lifecycle-livedata-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-process:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/2c63e08ad52ed05d2de70ae87b56f471/transformed/jetified-lifecycle-process-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/96a6fc2a6feb38f2bb5bdc9211883217/transformed/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core-ktx:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/5ac3db7a49aa4b085dd5211442fe1ddd/transformed/jetified-lifecycle-livedata-core-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.lifecycle:lifecycle-livedata-core:2.4.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/9bf0b36737bb24aabba1fc2d4c0566af/transformed/lifecycle-livedata-core-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.sqlite:sqlite-framework:2.2.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/f216fbfc86c0ee20eb02ba17f4047c4f/transformed/sqlite-framework-2.2.0/META-INF/com/android/build/gradle/aar-metadata.properties.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.sqlite:sqlite:2.2.0.
AAR metadata file: /Users/jdivock/.gradle/caches/transforms-3/ea7f145a1745e02f67969c1f56135568/transformed/sqlite-2.2.0/META-INF/com/android/build/gradle/aar-metadata.properties.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: /Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar.
> Failed to transform '/Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
3: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:desugarDebugFileDependencies'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=processed-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: /Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar.
> Failed to transform '/Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
4: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=android-java-res, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: /Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar.
> Failed to transform '/Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
5: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform moshi-1.13.0.jar (com.squareup.moshi:moshi:1.13.0) to match attributes {artifactType=android-java-res, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for JetifyTransform: /Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar.
> Failed to transform '/Users/jdivock/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.13.0/da685586facab9eb5c4fb630ce248be14e7da21b/moshi-1.13.0.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 60. (Run with --stacktrace for more details.)
Suggestions:
- Check out existing issues at https://issuetracker.google.com/issues?q=componentid:460323&s=modified_time:desc, it's possible that this issue has already been filed there.
- If this issue has not been filed, please report it at https://issuetracker.google.com/issues/new?component=460323 (run with --stacktrace and provide a stack trace if possible).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
==============================================================================
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2m 18s
268 actionable tasks: 260 executed, 8 up-to-date
This is due to an incompatibility between Expo and Terminal Android SDK v2.7.0. Expo uses compileSdkVersion = 30
, but some dependencies in the Terminal Android SDK require 31. The only way around this is to have Expo update to 31, or downgrade the embedded Terminal Android SDK to 2.6.0.
Expo has at least one open PR (https://github.com/expo/expo/pull/16614) that partially addresses the problem. I'll look into submitting an Expo PR that updates to 31 across the whole project.
Alright
Managed to get it working by updating minSDK version and updating jetifier to ignore moshi, however the app fails on load as it doesn't have location perms. @arekkubaczkowski should the expo plugin do this for us like it does with iOS? Seems like we need to add the android BT code here: https://github.com/stripe/stripe-terminal-react-native/blob/main/src/plugin/withStripeTerminal.ts
@jdivock-stripe all described here https://github.com/stripe/stripe-terminal-react-native/pull/210#issuecomment-1080259128
@arekkubaczkowski were you able to try any of that guidance? Updating both the manifest and adding the runtime code works for location but not for either bluetooth permission
huh… that's odd, the BT perms don't even exist within PermissionsAndroid
PermissionsAndroid {
"PERMISSIONS": Object {
"ACCESS_BACKGROUND_LOCATION": "android.permission.ACCESS_BACKGROUND_LOCATION",
"ACCESS_COARSE_LOCATION": "android.permission.ACCESS_COARSE_LOCATION",
"ACCESS_FINE_LOCATION": "android.permission.ACCESS_FINE_LOCATION",
"ADD_VOICEMAIL": "com.android.voicemail.permission.ADD_VOICEMAIL",
"BODY_SENSORS": "android.permission.BODY_SENSORS",
"CALL_PHONE": "android.permission.CALL_PHONE",
"CAMERA": "android.permission.CAMERA",
"GET_ACCOUNTS": "android.permission.GET_ACCOUNTS",
"PROCESS_OUTGOING_CALLS": "android.permission.PROCESS_OUTGOING_CALLS",
"READ_CALENDAR": "android.permission.READ_CALENDAR",
"READ_CALL_LOG": "android.permission.READ_CALL_LOG",
"READ_CONTACTS": "android.permission.READ_CONTACTS",
"READ_EXTERNAL_STORAGE": "android.permission.READ_EXTERNAL_STORAGE",
"READ_PHONE_STATE": "android.permission.READ_PHONE_STATE",
"READ_SMS": "android.permission.READ_SMS",
"RECEIVE_MMS": "android.permission.RECEIVE_MMS",
"RECEIVE_SMS": "android.permission.RECEIVE_SMS",
"RECEIVE_WAP_PUSH": "android.permission.RECEIVE_WAP_PUSH",
"RECORD_AUDIO": "android.permission.RECORD_AUDIO",
"SEND_SMS": "android.permission.SEND_SMS",
"USE_SIP": "android.permission.USE_SIP",
"WRITE_CALENDAR": "android.permission.WRITE_CALENDAR",
"WRITE_CALL_LOG": "android.permission.WRITE_CALL_LOG",
"WRITE_CONTACTS": "android.permission.WRITE_CONTACTS",
"WRITE_EXTERNAL_STORAGE": "android.permission.WRITE_EXTERNAL_STORAGE",
},
"RESULTS": Object {
"DENIED": "denied",
"GRANTED": "granted",
"NEVER_ASK_AGAIN": "never_ask_again",
},
}
code here: jay-rn-expo-app-master (3).zip
that's funny, it seems like Expo doesn't support BT permissions yet 😐 the only workaround that I found is requesting for those permissions directly from Android, e.g. from MainActivity.java:
public class MainActivity extends ReactActivity {
Integer BLUETOOTH_PERMISSIONS_REQUEST_CODE = 5001;
@RequiresApi(api = Build.VERSION_CODES.S)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(null);
requestPermissions(new String[]{
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT},
BLUETOOTH_PERMISSIONS_REQUEST_CODE);
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (requestCode == BLUETOOTH_PERMISSIONS_REQUEST_CODE && grantResults.length > 0 && (grantResults[0] != PackageManager.PERMISSION_GRANTED)) {
throw new RuntimeException("Bluetooth permissions are required in order to connect to a reader.");
}
}
there is a second workaround, the library can be used that handles RN permissions: https://github.com/zoontek/react-native-permissions but it still requires to first add them to AndroidManifest.xml:
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
and next:
import {PERMISSIONS, RESULTS,request} from 'react-native-permissions';
const grantedBT = await request(PERMISSIONS.ANDROID.BLUETOOTH_CONNECT)
const grantedBTScan = await request(PERMISSIONS.ANDROID.BLUETOOTH_SCAN)
if (
grantedBT === RESULTS.GRANTED &&
grantedBTScan === RESULTS.GRANTED
) {
initialize({ logLevel: "verbose" });
} else {
return;
}
huh… got it and thanks for digging in! Let me poke around and see if I can use all this to work it into our own plugin.
https://github.com/expo/config-plugins/tree/main/packages/react-native-ble-plx has some solid prior art to go off of (which also doesn't work with expo / android 12 permissioning :-/ )
@jdivock-stripe nice find, let me know once you get some details
alright, nice, using the external lib to work through android permissions worked, let me circle back and work it into the expo plugin
expo start
a
to build android with an android phone connected to usbadded
android:exported="true"
to the manifest with no changeremoving any
import
's of the terminal RN SDK resolves the issuejay-rn-expo-app-master (2).zip