Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native run-android plugin not found and compile sdk is not specified

When running command npx react-native run-android --port=80 --verbose I get error:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=80

And then above that I can see:

1: Task failed with an exception.

-----------
* Where:
Build file 'C:\location\node_modules\react-native-create-thumbnail\android\build.gradle' line: 23

* What went wrong:
A problem occurred evaluating project ':react-native-create-thumbnail'.
> Plugin with id 'maven' not found.

* 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:
A problem occurred configuring project ':react-native-create-thumbnail'.
> compileSdkVersion is not specified.

* 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.
==============================================================================

What I have done so far:

  1. Created a fresh project and seen that working to ensure my development environment is functioning correctly enter image description here

  2. In gradle-wrapper.properties set the distributionUrl to https\://services.gradle.org/distributions/gradle-7.0-all.zip

  3. Ensured correct SDK versions are installed enter image description here

  4. Checked versions in code

def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

buildscript {
    // The Android Gradle plugin is only required when opening the android folder stand-alone.
    // This avoids unnecessary downloads and potential conflicts when the library is included as a
    // module dependency in an application project.
    // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
    if (project == rootProject) {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.4.1'
        }
    }
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
    compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
    buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
        targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    // ref: https://www.baeldung.com/maven-local-repository
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
    maven {
        // Android JSC is installed from npm
        url "$rootDir/../node_modules/jsc-android/dist"
    }
    google()
    jcenter()
}

I'm at a loss here, any help would be greatly appreciated.

like image 246
Sparkeroo Avatar asked Nov 14 '22 22:11

Sparkeroo


1 Answers

Gradle 7.0 removed support for maven and now you need maven-publish https://docs.gradle.org/7.0/userguide/publishing_maven.html#publishing_maven

similar to SO: Plugin with id 'maven' not found

like image 128
turtlehacker Avatar answered Dec 16 '22 03:12

turtlehacker