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.

Error building Litho with React Native: Bad service configuration file, or exception thrown while constructing Processor object:...

See original GitHub issue

Version

compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.facebook.react:react-native:+"  // From node_modules

// Litho
compile 'com.facebook.litho:litho-core:0.14.0'
compile 'com.facebook.litho:litho-widget:0.14.0'
provided 'com.facebook.litho:litho-annotations:0.14.0'

annotationProcessor 'com.facebook.litho:litho-processor:0.14.0'

// SoLoader
compile 'com.facebook.soloader:soloader:0.2.0'

// For integration with Fresco
compile 'com.facebook.litho:litho-fresco:0.14.0'

// For testing
testCompile 'com.facebook.litho:litho-testing:0.14.0'

// Sections
compile 'com.facebook.litho:litho-sections-core:0.14.0'
compile 'com.facebook.litho:litho-sections-widget:0.14.0'
provided 'com.facebook.litho:litho-sections-annotations:0.14.0'

annotationProcessor 'com.facebook.litho:litho-sections-processor:0.14.0'

Issues and Steps to Reproduce

Attempting to integrate Litho with React Native. I have followed “Getting Started” and FAQs Using Litho with React Native. Gradle is syncing successfully, but when I build the project it comes back with this error:

error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider com.facebook.litho.specmodels.processor.ComponentsProcessor could not be instantiated: java.lang.NoClassDefFoundError: com/facebook/litho/annotations/FromPrepare

FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:compileDebugJavaWithJavac’.

Compilation failed; see the compiler error output for details.

Expected Behavior

Project can build without errors. Project is extremely bare bones, haven’t added any additional code to my MainActivity or MainApplication file, everything fresh from react-native init with a react-native run-android

Link to Code

My App build.gradle file

 apply plugin: "com.android.application"
 import com.android.build.OutputFile
 project.ext.react = [
     entryFile: "index.js"
 ]
 apply from: "../../node_modules/react-native/react.gradle"
 def enableSeparateBuildPerCPUArchitecture = false
 def enableProguardInReleaseBuilds = false
 android {
   compileSdkVersion 27
   buildToolsVersion "27.0.1"

  defaultConfig {
      applicationId "com.lithodiscovery"
      minSdkVersion 18
      targetSdkVersion 27
      versionCode 1
      versionName "1.0"
      ndk {
          abiFilters "armeabi-v7a", "x86"
      }
  }
  splits {
      abi {
          reset()
          enable enableSeparateBuildPerCPUArchitecture
          universalApk false  // If true, also generate a universal APK
          include "armeabi-v7a", "x86"
      }
  }
  buildTypes {
      release {
          minifyEnabled enableProguardInReleaseBuilds
          proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
      }
  }
  // applicationVariants are e.g. debug, release
  applicationVariants.all { variant ->
      variant.outputs.each { output ->
          // For each separate APK per architecture, set a unique version code as described here:
          // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
          def versionCodes = ["armeabi-v7a":1, "x86":2]
          def abi = output.getFilter(OutputFile.ABI)
          if (abi != null) {  // null for the universal-debug, universal-release variants
              output.versionCodeOverride =
                      versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
          }
      }
   }
}

configurations.all {
    exclude group: 'com.facebook.yoga', module: 'yoga'
    exclude group: 'com.facebook.litho', module: 'litho-annotations'
    resolutionStrategy {
        force 'com.google.code.findbugs:jsr305:1.3.9'
        force 'com.android.support:appcompat-v7:26.+'
        force 'com.android.support:support-compat:26.+'
        force 'com.android.support:support-core-ui:26.+'
        force 'com.android.support:support-annotations:26.+'
        force 'com.android.support:recyclerview-v7:26.+'
   }
}

  dependencies {
  compile fileTree(dir: "libs", include: ["*.jar"])
  compile "com.facebook.react:react-native:+"  // From node_modules

  // Litho
  compile 'com.facebook.litho:litho-core:0.14.0'
  compile 'com.facebook.litho:litho-widget:0.14.0'
  provided 'com.facebook.litho:litho-annotations:0.14.0'

  annotationProcessor 'com.facebook.litho:litho-processor:0.14.0'

  // SoLoader
  compile 'com.facebook.soloader:soloader:0.2.0'

  // For integration with Fresco
  compile 'com.facebook.litho:litho-fresco:0.14.0'

  // For testing
  testCompile 'com.facebook.litho:litho-testing:0.14.0'

  // Sections
  compile 'com.facebook.litho:litho-sections-core:0.14.0'
  compile 'com.facebook.litho:litho-sections-widget:0.14.0'
  provided 'com.facebook.litho:litho-sections-annotations:0.14.0'

  annotationProcessor 'com.facebook.litho:litho-sections-processor:0.14.0'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

My Project build.gradle file

 buildscript {
     repositories {
         jcenter()
     }
     dependencies {
          classpath 'com.android.tools.build:gradle:2.3.1'

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
  }

allprojects {
    repositories {
       mavenLocal()
       jcenter()
       maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
       }
       maven { url 'https://maven.google.com' }
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
DropKode21commented, May 22, 2018

Yes all good!, Thanks again @passy

1reaction
DropKode21commented, May 18, 2018

All good, thanks again @passy for all your help. Got it up and going with 13. Now for the fun part of bridging it to react native. Wish me luck.

Also if anyone has any leads they don’t mind sharing on the subject, any advice is appreciated. Thank you in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Bad service configuration file, or exception thrown while ...
I have resolved the following issue just by deleting the Target folder of annotation-processor and compiled the framework again.
Read more >
facebook/litho - Gitter
Hello Everyone, I'm trying to get litho up going in my React Native ... by error: Bad service configuration file, or exception thrown...
Read more >
FAQ - Litho
React Native ships with its own version of Yoga which can cause conflicts when merging the dex files. In order to avoid this,...
Read more >
Handbook of Suggested Practices for the Design and ...
design, construction, and installation of ground-water monitoring wells. This document does not focus on specific regulatory requirements, ...
Read more >
Pages - Dashboard - Esko
KB64979024: Automation Engine - How to configure the SQL Server for Automation ... Engine - Problem while copying files, Creating directory failed error....
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