0

I'm trying to add the JCodec library to my android studio project. I followed the steps listed here. I import these four lines:

    import org.jcodec.codecs.h264.H264Decoder;
    import org.jcodec.common.AndroidUtil;
    import org.jcodec.common.model.ColorSpace;
    import org.jcodec.common.model.Picture;

I get no errors until I build my project. When I build the project, I get an error that each of the packages I tried to import don't exist. Does anyone know what the problem is?

Thanks!

Community
  • 1
  • 1

2 Answers2

1

I did not really understand how linked answer helped you to add library because it is for Eclipse and you are using Android Studio and Gradle.

In build.gradle you should add:

dependencies {
   ...
   compile 'org.jcodec:jcodec:0.1.9'
   ...
}
mixel
  • 25,177
  • 13
  • 126
  • 165
  • I used Eclipse just to compile the library and then added the library on android studio by going to 'project structure' and then add a library under libraries. – user5382735 Sep 28 '15 at 00:36
  • I don't think I have a build.gradle file. The project I am using was also originally an Eclipse file that I imported to Android Studio. Is there another place I can tell it to compile jcodec? – user5382735 Sep 28 '15 at 00:37
  • I think my problem is that I added jcodec library as an external library. I'm trying to see how to add it a different way – user5382735 Sep 28 '15 at 01:01
  • Is jcodec library a `jar` file? In libraries under Project structure there should be possibility to mark library as compile or runtime dependency. You should mark it as compile dependency. I suggest you to migrate to default development workflow with Android Studio and Gradle. It's not that hard and you will get useful experience. – mixel Sep 28 '15 at 07:07
  • It was marked as compile. The issue was that I added it under libraries but it wasn't a jar file, it was an android project. What I did to solve the problem was adding it as a module and then adding the module as a dependency to my project. Thanks for your help – user5382735 Sep 28 '15 at 16:05
  • I am still confused about how to add JCodec to my android studio project. You can define the dep for the core jcodec as shown above, but that doesn't include any of the android specific stuff you need. There is a java-se jar you can download, but again, I think that is kind of worthless for android. So I ended up just adding the android specific code under my src tree so I could use AndroidUtils. Hopefully it will have a Jcodec android specific artifact on MavenCentral in the next release. – medloh Oct 15 '15 at 16:31
1

I figured out my problem. The issue was that I added the library under libraries but it wasn't a jar file, it was an android project. What I did to solve the problem was adding it as a module and then adding the module as a dependency to my project.