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' }
}
}