Build fails with Android SDK 31
Error:
Error:
android:exported needs to be explicitly specified for <service>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.
I found it's agora using this answer. Generated manifest (see it's missing exported for activity and service):
<activity
android:name="io.agora.rtc.ss.impl.ScreenSharing$LocalScreenCaptureAssistantActivity"
android:configChanges="screenSize|orientation"
android:screenOrientation="fullUser"
android:theme="@android:style/Theme.Translucent" />
<service
android:name="io.agora.rtc.ss.impl.LocalScreenSharingService"
android:foregroundServiceType="mediaProjection" >
<intent-filter>
<action android:name="android.intent.action.screenshare" />
</intent-filter>
</service>
Patch (add this to your manifest):
<activity android:name="io.agora.rtc.ss.impl.ScreenSharing$LocalScreenCaptureAssistantActivity"
android:exported="false"
tools:node="merge" />
<service
android:name="io.agora.rtc.ss.impl.LocalScreenSharingService"
android:exported="false"
android:foregroundServiceType="mediaProjection" tools:node="merge" />
I just came here following a similar path. Took a while to find the culprit and the solution. Thanks for posting!
I added:
<service android:exported="true" android:foregroundServiceType="mediaProjection" android:name="io.agora.rtc.ss.impl.LocalScreenSharingService"> <intent-filter> <action android:name="android.intent.action.screenshare"/> </intent-filter> </service>
@LichKing-2234 I can confirm the above issue. Can we update the SDK to avoid this workaround while building the app for Android SDK 31?
It will be fixed in the next version. You can use the workaround before.
Where to put the service tag in manifest in agora manifest or app manifest?
@ohowajiha your app manifest
Hi there.
any update?
is there a solution for Expo EAS Build (Managed App)? with the same error message.

OR how to fix this error at Runtime (without Rebuilding Expo Managed App)?

You can patch-package the build.gradle file to point at the more recent AAR with the fix, which is an approach that's compatible with Expo's managed workflow. Below is the react-native-agora+3.7.0.patch file to use with patch-package:
diff --git a/node_modules/react-native-agora/android/build.gradle b/node_modules/react-native-agora/android/build.gradle
index 5e66c96..9f5a1bf 100644
--- a/node_modules/react-native-agora/android/build.gradle
+++ b/node_modules/react-native-agora/android/build.gradle
@@ -128,7 +128,7 @@ dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
api 'io.agora.rtc:full-sdk:3.7.0'
- implementation 'io.agora.rtc:full-screen-sharing:3.7.0'
+ implementation 'io.agora.rtc:full-screen-sharing:3.7.0.204.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
A million thanks to @kbrandwijk and @EkaanshArora for their input, feedback, and support.
I can now finally build the Expo native client for Android with the following BASH script that creates a brand-new Expo project, installs the NPMs, patches react-native-agora, then runs the EAS Build.
rm -rf repro-1101
expo init --npm -t blank repro-1101
cd repro-1101
# install Expo libs
#
expo install expo-dev-client
expo install react-native-agora agora-rn-uikit agora-react-native-rtm
# have to patch react-native-agora to fix Issue 1101
#
npm install -D patch-package
mkdir patches
cat <<EOF > patches/react-native-agora+3.7.0.patch
diff --git a/node_modules/react-native-agora/android/build.gradle b/node_modules/react-native-agora/android/build.gradle
index 5e66c96..9f5a1bf 100644
--- a/node_modules/react-native-agora/android/build.gradle
+++ b/node_modules/react-native-agora/android/build.gradle
@@ -128,7 +128,7 @@ dependencies {
// noinspection GradleDynamicVersion
api 'com.facebook.react:react-native:+'
api 'io.agora.rtc:full-sdk:3.7.0'
- implementation 'io.agora.rtc:full-screen-sharing:3.7.0'
+ implementation 'io.agora.rtc:full-screen-sharing:3.7.0.204.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:\$kotlin_version"
}
EOF
# add postinstall script to package.json
#
npm install -D json
$(npm bin)/json -I -f package.json -e "this.scripts.postinstall=\"patch-package\""
# apply the patch
#
npm install
# do EAS Build
#
eas build:configure -p all
eas build -p android --profile development
set +x
echo "done"
I had to update manually
/node_modules/react-native-agora/android/build.gradle
because got some errors from patch-package.
Just changed:
implementation 'io.agora.rtc:full-screen-sharing:3.7.0' <-- this
implementation 'io.agora.rtc:full-screen-sharing:3.7.0.204.1' <-- by this one
after that i run
npx patch-package react-native-agora
then build with EAS and everything works!!
The fix from @kuriel-trivu solves it for me as well - I took the liberty of opening a PR with the suggested changes.
The reason I patched, instead of PR'd, was because it was mentioned in this comment that it would already be fixed in the next version: https://github.com/AgoraIO-Community/react-native-agora/issues/496#issuecomment-1139433362
@LichKing-2234 is this fixed now?
I think the 3.7.1 version has fixed it.