How to remove the plugins from android subprojects using app.config.js or config-plugins?

SDK Version: 44
Platforms(Android/iOS/web/all): Android

Command expo run:android failed with following Error Log

The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle ‘plugins { … }’ DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add ‘apply false’ to the plugin line.
See: Using Gradle Plugins
The Kotlin plugin was loaded in the following projects: ‘:expo-updates-interface’, ‘:react-native-pdf-thumbnail’

Task :expo-updates:kaptGenerateStubsDebugKotlin FAILED
e: [kapt] ‘com.sun.tools.javac.util.Context’ class can’t be found (‘tools.jar’ is absent in the plugin classpath). Kapt won’t work.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:expo-updates:kaptGenerateStubsDebugKotlin’.

Compilation error. See log for more details

  • 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 Command-Line Interface

BUILD FAILED in 17s
787 actionable tasks: 4 executed, 783 up-to-date
/Users/user/Projects/App/android/gradlew exited with non-zero code: 1
Error: /Users/user/Projects/App/android/gradlew exited with non-zero code: 1
at ChildProcess.completionListener (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
at Object.onceWrapper (events.js:483:26)
at ChildProcess.emit (events.js:376:20)
at maybeClose (internal/child_process.js:1055:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

at spawnAsync (/usr/local/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
at spawnGradleAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:83:18)
at assembleAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/spawnGradleAsync.ts:57:16)
at actionAsync (/usr/local/lib/node_modules/expo-cli/src/commands/run/android/runAndroid.ts:143:9)

My Questions are

How to remove the plugins from android subprojects using app.config.js or config-plugins?
Is there any other way to resolve it without making change in subprojects in root android folder (As it’s not recommended to modify native projects)

Hey @endometriose, can you share your app.config.js or app.json file as well as what the command npx expo-env-info prints out?

Result of npx expo-env-info

expo-env-info 1.0.2 environment info:
    System:
      OS: macOS 12.3
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.17.0 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 7.19.1 - /usr/local/bin/npm
      Watchman: 2021.08.30.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.11.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
      Android SDK:
        API Levels: 22, 25, 26, 27, 28, 29, 30, 31, 32
        Build Tools: 26.0.2, 27.0.3, 28.0.3, 29.0.1, 29.0.2, 29.0.3, 30.0.0, 30.0.1, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0
        System Images: android-30 | Google APIs Intel x86 Atom, android-32 | Google APIs Intel x86 Atom_64
    IDEs:
      Android Studio: 2021.1 AI-211.7628.21.2111.8092744
      Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
    npmPackages:
      @expo/metro-config: ^0.3.11 => 0.3.11 
      babel-preset-expo: 9.0.2 => 9.0.2 
      expo: ^44.0.6 => 44.0.6 
      react: 17.0.1 => 17.0.1 
      react-dom: 17.0.1 => 17.0.1 
      react-native: 0.64.3 => 0.64.3 
      react-native-web: 0.17.1 => 0.17.1 
      react-navigation: ^4.4.0 => 4.4.4 
    npmGlobalPackages:
      eas-cli: 0.48.2
      expo-cli: 5.3.0
    Expo Workflow: bare

app.config.js

const ENV_DEVELOPMENT = 'dev';
const ENV_PRODUCTION = 'prod';
const ENV_STAGING = 'stage';

const ENVIRONMENT = process.env.ENVIRONMENT;

const PROD_PACKAGE = "..."
const STAGE_PACKAGE = "..."
const DEV_PACKAGE = "..."

const PROD_BUNDLE_IDENTIFIER = "..."
const STAGE_BUNDLE_IDENTIFIER = "..."
const DEV_BUNDLE_IDENTIFIER = "..."

const PACKAGE_NAME = ENVIRONMENT === ENV_PRODUCTION ? PROD_PACKAGE :
    ENVIRONMENT === ENV_STAGING ? STAGE_PACKAGE :
        DEV_PACKAGE

const BUNDLE_IDENTIFIER = ENVIRONMENT === ENV_PRODUCTION ? PROD_BUNDLE_IDENTIFIER :
    ENVIRONMENT === ENV_STAGING ? STAGE_BUNDLE_IDENTIFIER :
        DEV_BUNDLE_IDENTIFIER

const APP_NAME = ENVIRONMENT === ENV_PRODUCTION ? "Endo-App" :
    ENVIRONMENT === ENV_STAGING ? "Endo-App[Stage]" :
        "Endo-App[Dev]"

const EXPO_URL = ENVIRONMENT === ENV_PRODUCTION ? "..." :
    ENVIRONMENT === ENV_STAGING ? "..." :
        "..."

const ENV_VALUE = ENVIRONMENT === ENV_PRODUCTION ? "prod" :
    ENVIRONMENT === ENV_STAGING ? "stage" :
        "dev"
        
const version = "1.1.72"
const buildNumber = 178

export default {
    expo: {
        name: APP_NAME,
        slug: "...",
        version: version,
        orientation: "portrait",
        icon: "./assets/images/icon.png",
        scheme: "endo-app",
        splash: {
            image: "./assets/images/splash.png",
            resizeMode: "contain",
            backgroundColor: "#ffffff"
        },
        extra: {
            env: ENV_VALUE
        },
        updates: {
            fallbackToCacheTimeout: 0
        },
        assetBundlePatterns: [
            "**/*",
            "assets/fonts/*",
            "assets/images/*",
            "assets/video/*",
            "assets/images/svgs/*"
        ],
        notification: {
            icon: "./assets/images/icon.png"
        },
        ios: {
            bundleIdentifier: BUNDLE_IDENTIFIER,
            buildNumber: `${buildNumber}`,
            supportsTablet: true,
            infoPlist: {
                ITSAppUsesNonExemptEncryption: false
            }
        },
        android: {
            package: PACKAGE_NAME,
            versionCode: buildNumber,
            useNextNotificationsApi: true,
            adaptiveIcon: {
                foregroundImage: "./assets/images/adaptive-icon.png",
                backgroundColor: "#A22A52"
            }
        },
        web: {
            favicon: "./assets/images/favicon.png",
            config: {
                firebase: {
                    apiKey: "...",
                    authDomain: "...",
                    databaseURL: "...",
                    projectId: "...",
                    storageBucket: "...",
                    messagingSenderId: "...",
                    appId: "...",
                    measurementId: "..."
                }
            }
        },
        description: "",
        packagerOpts: {
            config: "metro.config.js",
            sourceExts: [
                "expo.ts",
                "expo.tsx",
                "expo.js",
                "expo.jsx",
                "ts",
                "tsx",
                "js",
                "jsx",
                "json",
                "wasm",
                "svg",
                "ttf"
            ]
        },
        hooks: {
            postPublish: [
                {
                    file: "sentry-expo/upload-sourcemaps",
                    config: {
                        organization: "...",
                        project: "...",
                        authToken: "..."
                    }
                },
                {
                    file: "./notify",
                    config: {
                        webhookUrl: "..."
                    }
                }
            ]
        },
        plugins: [
            "sentry-expo",
        ]
    }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.