Am i using the Glide library wrongly? what could be the problem?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView iv = (ImageView) findViewById(R.id.imageView1);
Glide.with(this).load(R.drawable.salads_caesar_salad).into(iv);
}
If your code compiles fine it's highly likely you have the right dependencies on the compile classpath. If you use Android Studio/Gradle it's possible that ProGuard somehow strips the Glide class for whatever reason, but it really shouldn't because you're actually using it.
The above contradicition and the fact that your LogCat screenshot is either that of Eclipse ADT or Android Device Monitor (
monitor.bat
) leaves one option: you didn't export your dependency; try the following (see the screenshot in the linked manual):glide.jar
is tickedAlternatively consider re-creating your project in Android Studio (official Google product for Android development) or IntelliJ IDEA 14+ and copying your sources over; the IntelliJ Android Plugin has much better support for Android and modern build tools than Eclipse ADT. I was really against the transition myself, but as you see it worked, because now I'm advocating for it. It's worth a day or two effort in the long run.
You need to add Glide library to your android project.
If you using gradle:
If you are using maven:
You can also add library directly to your project in your
Eclipse
: right-click on your project's properties then Library section then click Add to add the library.If you are using
Android Studio
: http://www.truiton.com/2015/02/android-studio-add-library-project/you seem to import the glide library wrongly -
the NoClassDefFoundError results of the fact that the android build does not find your glide library.
In the android studio you can add it in "project structure" via adding the library glide to your dependencies. Check out the general strategy here
I think you can only load URL's, and you can only use Resources in the .error() and .placeholder() methods according to their documentation. https://github.com/bumptech/glide
And why would you use glide when you can straight set the resource in the imageview like this:
I hope it helps!