Skip to content

Commit

Permalink
Updates to build in React Native/Expo project
Browse files Browse the repository at this point in the history
Update min/target/compile Sdk versions to 21,31,31 respectively
Move namespace definition from manifest to build.gradle file
Include manufacturer and product names in device list
Add MUTABLE flag to pending intent (required by newer SDK)
  • Loading branch information
shancock884 committed Jan 27, 2024
1 parent b28e12a commit 5cb9235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ buildscript {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileSdkVersion 31

namespace "com.melihyarikkaya.rnserialport"

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 16
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
}
Expand Down
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.melihyarikkaya.rnserialport">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.usb.host"
android:required="true"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ public void getDeviceList(Promise promise) {
map.putString("name", d.getDeviceName());
map.putInt("vendorId", d.getVendorId());
map.putInt("productId", d.getProductId());
map.putString("manufacturerName", d.getManufacturerName());
map.putString("productName", d.getProductName());

deviceList.pushMap(map);
}
Expand Down Expand Up @@ -737,7 +739,7 @@ public void onReceivedData(byte[] bytes) {
private void requestUserPermission(UsbDevice device) {
if(device == null)
return;
PendingIntent mPendingIntent = PendingIntent.getBroadcast(mReactContext, 0 , new Intent(ACTION_USB_PERMISSION), 0);
PendingIntent mPendingIntent = PendingIntent.getBroadcast(mReactContext, 0 , new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE);
usbManager.requestPermission(device, mPendingIntent);
}

Expand Down

0 comments on commit 5cb9235

Please sign in to comment.