Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gettign react native build error after mappls-react-native-sdk setup from documantation #7

Closed
nirali-kp opened this issue Mar 22, 2024 · 14 comments

Comments

@nirali-kp
Copy link

nirali-kp commented Mar 22, 2024

I am getting this build error after i followed all steps given here
Documantation
to integrate mapmyindia in my react-native project.


BUILD FAILED in 15s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Could not determine the dependencies of task ':app:processDebugResources'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. > Could not find com.mappls.sdk:mappls-android-sdk:8.1.2.

pls help on how to fix.

@nirali-kp
Copy link
Author

@Saksham66 @spacekingindia @mamtasharma117 Are you guys available to help here? On website too nobody replies on time and available to help. And also sent mail to apisupport@mappls.com but nobody has answered my query yet. Very poor and bad service mapmyindia provides.

@Saksham66
Copy link
Collaborator

Please add maven url in your project level build.gradle or settings.gradle:
maven { url 'https://maven.mappls.com/repository/mappls/'}

@Nitin-Baghel
Copy link

Nitin-Baghel commented Mar 26, 2024

Hi @Saksham66, @spacekingindia , @mamtasharma117, @nirali-kp,

I recently integrated mapmyindia in my React-Native project and followed the steps given in the documentation but I also faced same error as @nirali-kp raised above and tried the solution you have provided above but its not working and gave below error:


BUILD FAILED in 1s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * Where:
Settings file '/home/nitin/Documents/RN/MyDemoApp/android/settings.gradle' line: 8 * What went wrong:
A problem occurred evaluating settings 'MyDemoApp'.
> Could not find method url() for arguments [https://maven.mappls.com/repository/mappls/] on settings 'MyDemoApp' of type org.gradle.initialization.DefaultSettings. * 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. BUILD FAILED in 1s.
info Run CLI with --verbose flag for more details.

Also @Saksham66, I observed the solution you have provided to add
maven { url 'https://maven.mappls.com/repository/mappls/'}
in setting.gradle file seems incorrect since it is to be added in project/android/build.gradle as per the documentation given.
Mappls React Native SDK

Now please guide how we can fix this asap.

@Saksham66
Copy link
Collaborator

For older Build versions (i.e, Before gradle v7.0.0)

Add Mappls repository in your project level build.gradle

 allprojects {  
    repositories {  
  
        maven {  
            url 'https://maven.mappls.com/repository/mappls/'  
        }  
    }  
}  

For Newer Build Versions (i.e, After gradle v7.0.0)

Add Mappls repository in your settings.gradle

dependencyResolutionManagement {  
//   repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)  
  repositories {  
        google()  
        mavenCentral()  
        maven {  
            url 'https://maven.mappls.com/repository/mappls/'  
        }  
    }  
   }  
}  

@Nitin-Baghel
Copy link

Nitin-Baghel commented Mar 26, 2024

Hi @Saksham66,

I have already added above code as it is guided in mapmyindia documentation still I am getting build failed error
I am attaching all the screen shots with build version and error message I am getting for your reference.

Screenshot from 2024-03-26 20-37-00
Screenshot from 2024-03-26 20-37-54
Screenshot from 2024-03-26 20-38-03
Screenshot from 2024-03-26 20-38-12

@Saksham66
Copy link
Collaborator

Hi @Nitin-Baghel

Can you please share your complete build.gradle file because as in the above error mappls SDK is not searched in maven.mappls.com

@Nitin-Baghel
Copy link

Hi @Saksham66,

Sure I am sharing both gradle file for your reference.

code of project label gradle android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"
    }
    repositories {
        google()
        mavenCentral()
        maven { url 'https://maven.mappls.com/repository/mappls/'}
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    }
}

apply plugin: "com.facebook.react.rootproject"

code of android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

android {
    ndkVersion rootProject.ext.ndkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    compileSdk rootProject.ext.compileSdkVersion

    namespace "com.mydemoapp"
    defaultConfig {
        applicationId "com.mydemoapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation("com.facebook.react:flipper-integration")
    implementation project(':mappls-map-react-native')
    

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

@Saksham66
Copy link
Collaborator

Hi @Nitin-Baghel

You need to add maven url inside the allprojects tag. Your project level build.gradle should be:

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"
    }
    repositories {
        google()
        mavenCentral()
        maven { url 'https://maven.mappls.com/repository/mappls/'}
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    }
}

allprojects {
  repositories {
       maven { url 'https://maven.mappls.com/repository/mappls/'}
    }
}

apply plugin: "com.facebook.react.rootproject"

@aravi365
Copy link

after making the changes mentioned by @Saksham66 i am getting the below error:

Could not resolve all files for configuration ':mappls-map-react-native:androidJdkImage'. > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

@Saksham66
Copy link
Collaborator

Hi @aravi365
Can you share the complete Error logs for more detail?

@aravi365
Copy link

Here is the full error log @Saksham66

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mappls-map-react-native:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':mappls-map-react-native:androidJdkImage'.     
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: C:\Users\userx\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar.
         > Error while executing process C:\Program Files\Microsoft\jdk-21.0.2.13-hotspot\bin\jlink.exe with arguments {--module-path C:\Users\userx\.gradle\caches\transforms-3\b2085ecdfeba810337908e7b03005635\transformed\output\temp\jmod --add-modules java.base --output C:\Users\userx\.gradle\caches\transforms-3\b2085ecdfeba810337908e7b03005635\transformed\output\jdkImage --disable-plugin system-modules}

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

BUILD FAILED in 25s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':mappls-map-react-native:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':mappls-map-react-native:androidJdkImage'. > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for JdkImageTransform: C:\Users\userx\AppData\Local\Android\Sdk\platforms\android-34\core-for-system-modules.jar. > Error while executing process C:\Program Files\Microsoft\jdk-21.0.2.13-hotspot\bin\jlink.exe with arguments {--module-path C:\Users\userx\.gradle\caches\transforms-3\b2085ecdfeba810337908e7b03005635\transformed\output\temp\jmod --add-modules java.base --output C:\Users\userx\.gradle\caches\transforms-3\b2085ecdfeba810337908e7b03005635\transformed\output\jdkImage --disable-plugin system-modules} * 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. BUILD FAILED in 25s.

@Saksham66
Copy link
Collaborator

Can you run npx react-native doctor and share the details also try with JDK 11

@aravi365
Copy link

@Saksham66 I was able to build the app after downgrading my jdk version to 17.

@Anupam-Kumar2505
Copy link

@Saksham66 i am getting a stylesource error after following the entire doc of react-native-mappls guide. the error says

TypeError: Cannot read property 'StyleSource' of null, js engine: hermes

any reason why?and can you help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants