soehler / androidsvg

Automatically exported from code.google.com/p/androidsvg
0 stars 0 forks source link

NoClassDefFoundError in SVGImageView.init() when used in app not using themes #33

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create an android activity that does not use themes
2. Initialize the SVGImageView class
3. java.lang.NoClassDefFoundError: com.caverock.androidsvg.R$styleable in 
SVGImageView.init at 
com.caverock.androidsvg.SVGImageView.init(SVGImageView.java:80)

What is the expected output? What do you see instead?
Fatal error when reaching this line in the init() function on line 80
TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, 
R.styleable.SVGImageView, defStyle, 0)

As a Hackish fix, i prepended a check for existence of the class before this 
line & it seems to work for me
try {
    Class.forName( "R.styleable.SVGImageView" );
} catch( ClassNotFoundException e ) {
    return;
}

What version of the product are you using? On what operating system?
version 1.2.1 on JellyBean

Original issue reported on code.google.com by srinathd...@gmail.com on 23 Mar 2014 at 7:28

GoogleCodeExporter commented 9 years ago
Thanks for the report.

Can you elaborate further on how you are creating the Activity and 
SVGImageView?  Are you using an XML layout, or creating the layout in code?

Original comment by paul.leb...@gmail.com on 24 Mar 2014 at 11:07

GoogleCodeExporter commented 9 years ago
Hi,

I'm creating it in code. As part of a soft keyboard provider I'm
programmatically creating a layout,  instantiating and adding a
SVGImageview and passing the layout back to the host.

So in that sense not really a traditional activity

Original comment by srinathd...@gmail.com on 25 Mar 2014 at 2:00

GoogleCodeExporter commented 9 years ago
In that case, wouldn't you be using the SVGImageView(Context context) 
constructor?  That one doesn't call init() so you shouldn't strike the issue 
with R.styleable.SVGImageView.

Original comment by paul.leb...@gmail.com on 25 Mar 2014 at 2:03

GoogleCodeExporter commented 9 years ago
Hmm ok got it... I'll do that instead.

Original comment by srinathd...@gmail.com on 25 Mar 2014 at 2:37

GoogleCodeExporter commented 9 years ago
I forgot to say, the other constructors are there for when Android instantiates 
the View from a layout file.  Thus you shouldn't need to use them.

Does the above solve your problem?  If so, I'll close the bug.

Original comment by paul.leb...@gmail.com on 25 Mar 2014 at 2:43

GoogleCodeExporter commented 9 years ago
Yes thanks for the help!

Original comment by srinathd...@gmail.com on 25 Mar 2014 at 2:48

GoogleCodeExporter commented 9 years ago
You're welcome.

Marking this bug "Invalid".

Original comment by paul.leb...@gmail.com on 25 Mar 2014 at 2:50

GoogleCodeExporter commented 9 years ago
I am getting this exact problem when using SVGImageView in and XML layout. I 
checked out your code and imported it into my project as an Android library. 

Original comment by sortofri...@gmail.com on 24 Oct 2014 at 4:00

GoogleCodeExporter commented 9 years ago
Oh, and this is with version 1.2.1 on Android 4.2.2

Original comment by sortofri...@gmail.com on 24 Oct 2014 at 4:11

GoogleCodeExporter commented 9 years ago
Have you marked the AndroidSVG project you created as a library?

Propertires->Android, then check/tick "Is Library"

Original comment by paul.leb...@gmail.com on 24 Oct 2014 at 4:21

GoogleCodeExporter commented 9 years ago
I posted the solution to my problem in 
http://code.google.com/p/androidsvg/issues/detail?id=34

Original comment by sortofri...@gmail.com on 26 Oct 2014 at 7:15