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

Unable to import Litho KComponent, ComponentScope and other Litho classes #978

Closed
1 task done
connorutting opened this issue Mar 12, 2024 · 2 comments
Closed
1 task done

Comments

@connorutting
Copy link

Version

0.49.0

Issues and Steps to Reproduce

  1. Create a new project in android studio
Screenshot 2024-03-12 at 2 15 46 PM
  1. Select these settings
Screenshot 2024-03-12 at 2 16 16 PM
  1. Update your dependencies in the gradle file
dependencies {
    implementation("androidx.core:core-ktx:1.9.0")
    implementation("androidx.appcompat:appcompat:1.6.1")
    implementation("com.google.android.material:material:1.11.0")
    implementation("androidx.constraintlayout:constraintlayout:2.1.4")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

    // Litho
    implementation ("com.facebook.litho:litho-core:0.49.0")
    implementation ("com.facebook.litho:litho-widget:0.49.0")

    // SoLoader
    implementation ("com.facebook.soloader:soloader:0.10.5")

    // For integration with Fresco
    implementation ("com.facebook.litho:litho-fresco:0.49.0")

    // For testing
    testImplementation ("com.facebook.litho:litho-testing:0.49.0")
}
  1. Run gradle sync

  2. Modify your MainActivity.kt file like so

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.facebook.litho.Component
import com.facebook.litho.ComponentScope
import com.facebook.litho.KComponent
import com.facebook.litho.LithoView
import com.facebook.litho.kotlin.widget.Text
import com.facebook.rendercore.dp

class MyActivity : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    val lithoView = LithoView.create(this /* context */, MyComponent())
    setContentView(lithoView)
  }
}

class MyComponent() : KComponent() {
  override fun ComponentScope.render(): Component {
    return Text(text = "Hello, World!", textSize = 50.dp)
  }
}

After doing this, I received errors saying "Unresolved reference" for these imports

import com.facebook.litho.ComponentScope
import com.facebook.litho.KComponent
import com.facebook.litho.kotlin.widget.Text

I also couldn't find the classes/imports with "Unresolved reference" in this folder or definition for them
Screenshot 2024-03-12 at 2 35 41 PM
Screenshot 2024-03-12 at 2 41 07 PM

Expected Behavior

I would say the expected behavior is just to import the classes for the tutorial

facebook-github-bot pushed a commit that referenced this issue Mar 13, 2024
Summary: as title, people also report in the github: #978

Reviewed By: adityasharat

Differential Revision: D54846985

fbshipit-source-id: 5641854e05f648c5d3f5948ce030adb5fb85b92e
@pengj
Copy link

pengj commented Mar 14, 2024

Thanks for reporting the issue. There is a bug in the maven publish plugin and we just revoked back. Could you please check v0.49.1 if it works for you?

@connorutting
Copy link
Author

@pengj Hey thanks for getting this resolved it is working, you can close this issue!

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

3 participants