question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build fails with Android SDK 31

See original GitHub issue

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" />

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:5
  • Comments:13

github_iconTop GitHub Comments

4reactions
kbrandwijkcommented, Jun 24, 2022

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"
 }
4reactions
akengercommented, May 13, 2022

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>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Studio error "Installed Build Tools revision 31.0.0 is ...
In SDK Manager, deselect 31.0.0 and try installing an older version (e.g., I've tried 30.0.3) and update "buildToolsVersion" in build.gradle to ...
Read more >
Android build fails with Android SDK Build-Tools 31.0.0 #1288
The build seems to ignore the pinned Android Build-Tools version. This issue started appearing in our build pipeline between July 19., 13:20 UTC ......
Read more >
Installed Build Tools revision 31.0.0-rc5 is corrupted
Problem. After updating to the latest Android 12 tools 31.0.0-rc5, the builds are failing. Here's the message: Build-tool 31.0.0 rc5 is missing DX...
Read more >
[Android] Android build fails when targeting SDK 31 and using ...
The issue is caused by Android Gradle Plugin incompatibility with build-tools 31.0.0. The same issue is reproducible with a project created in ...
Read more >
How to solve Android Studio Error: Installed Build Tools ...
In many blogs, you will find that the solution is to downgrade to the API 30, however, if you want to experiment with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found