Skip to content

Prevent NoClassDefFoundError crashing app using Sugar#362

Merged
sibelius merged 1 commit intochennaione:masterfrom
mitchyboy9:master
Dec 7, 2015
Merged

Prevent NoClassDefFoundError crashing app using Sugar#362
sibelius merged 1 commit intochennaione:masterfrom
mitchyboy9:master

Conversation

@mitchyboy9
Copy link
Copy Markdown
Contributor

Hi Satya,

I'm just getting started using Sugar ORM and it looks really good so far. However, I had trouble getting my app to run because I kept getting a NoClassDefFoundError when I included Sugar.

I had a jar file on my classpath which wasn't actually being used by the project. When Sugar tried to load a class from that library, my app crashed.

My guess is that because the library was not being used, the classes didn't actually get copied to the apk, or something like that.

I changed the catch clause in getDomainClass to catch all throwables. It doesn't seem to matter why we can't load a class, the result will be the same: if there is an error of any kind, we're not going to be able to use that class as a domain class.

Thanks,

Alex

…rName can also throw LinkageError and ExceptionInInitializerError.

If we silently ignore a ClassNotFoundException,  I don't see why we wouldn't ignore the others.
A NoClassDefFoundError coming out of this method was causing my application to crash, but it was actually fine that the class couldn't be loaded.
@sibelius
Copy link
Copy Markdown
Contributor

sibelius commented Dec 7, 2015

@nicolabeghin thanks, I will merge this PR

sibelius added a commit that referenced this pull request Dec 7, 2015
Prevent NoClassDefFoundError crashing app using Sugar
@sibelius sibelius merged commit 7f881a8 into chennaione:master Dec 7, 2015
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

Successfully merging this pull request may close these issues.

3 participants