1

Cannot get Android Native app to run, following Salesforce Trailhead Mobile module here: Salesforce Android Mobile Walkthrough.

I have installed Java SDK 1.8, and Android Studio 2.3. Using NPM version 4.1.1 and forcedroid version 5.0.1. I've installed forcedroid globally. I've followed the steps to create a new forcedroid mobile app listed on that page. Here they are:

At the command prompt, change to the directory where you want to store your project, then type:

forcedroid create

As forcedroid prompts you, enter the following values:

Application type: native

Application name: MyTrailNative

Package name: com.mytrail.android

Organization name: MyApps, Inc.

Output directory: TrailAndroidApps

When importing the project into Android Studio, it throws the following error:

Gradle sync failed: Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.

This is the first part of the offending code. It comes from this path C:..\TrailAndroidApps\node_modules\SalesforceMobileSDK-Android\libs\SmartSync\build.gradle

(I think it's identical to the code on the Github project page for the SalesForce Mobile SDK here)

SalesforceMobileSDK-Android:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

dependencies {
compile project(':libs:SmartStore')

}


android {
  compileSdkVersion 25
  buildToolsVersion '23.0.1'

  buildTypes {
  debug {
     testCoverageEnabled = true
      }
  }

I've tried researching this error on it's own, haven't been able to find anything that fixes this error. I've tried putting in these suggestions found here: Similar issue with a different project, but didn't resolve that error. I've looked at the Salesforce forums, but there was only one open question about this, and there was not a resolution.

0

Replaced forcedroid created code from the C:..\TrailAndroidApps\build.gradle file:

buildscript {
   repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
  }
}

allprojects {
  repositories {
    jcenter()
  }
}

With this code (directly from the Github repository here):

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
  }
}

plugins {
  id "com.jfrog.bintray" version "1.7.3"
}

allprojects {
  group = 'com.salesforce.mobilesdk'
  version = '5.0.1'
  repositories {
    maven {
      // All of React Native (JS, Android binaries) is installed from npm
      url "$rootProject.projectDir/node_modules/react-native/android"
    }
    jcenter()
  }
}

After this, the project does not give the error, and successfully builds. Unsure why this file wasn't automatically updated to the same code as the linked code by forcedroid? That would seem to make sense as it should be pulling from that repository. Also made sure to run command line and Android Studio as administrator but still had this happen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.