almosr / android-svg-code-render

Convert SVG files into Java source and use it in your Android app
Apache License 2.0
24 stars 3 forks source link

Compiler error in SVGImageView on Android for variable LAYER_TYPE_SOFTWARE #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Used cloned source code to install androidsvg as a Library Module in IntelliJ
2. The project has minSdkVersion=10 and is built using the Android-2.3.3 SDK 
(API 10)
3. Added androidsvg as a new library module to the main project module.

What is the expected output? What do you see instead?

Since I hadn't used anything from androidsvg yet I simply compiled the project. 
The compilation failed complaining:

java: <redacted path>/src/com/caverock/androidsvg/SVGImageView.java:164: cannot 
find symbol
symbol  : variable LAYER_TYPE_SOFTWARE
location: class com.caverock.androidsvg.SVGImageView

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

androidsvg 1.2 (I guess, I cloned from the repo today).
Android-2.3.3 running Java6

Please provide any additional information below:

The variable LAYER_TYPE_SOFTWARE shouldn't exist by itself with no declaration. 
I am guessing that the code actually wants to use View.LAYER_TYPE_SOFTWARE 
(introduced in API 11) but is inhibited by the fact that it needs to use 
reflection to cater for lower API Levels.

My Solution:

Based on this hypothesis I simply defined LAYER_TYPE_SOFTWARE using reflection 
and let the try-catch block deal with failure for lower API Levels by adding 
this line just above the use of LAYER_TYPE_SOFTWARE (on line 164):

int LAYER_TYPE_SOFTWARE = View.class.getField("LAYER_TYPE_SOFTWARE").getInt(new 
View(getContext()));

This fixed the compiler error and I was able to use SVGImageView in the layout 
files in my project without any more problem.

P.S. Great work on this project.

Original issue reported on code.google.com by a...@spoton.com on 31 Oct 2013 at 5:25

GoogleCodeExporter commented 9 years ago
Fixed in local revision 269.

Fixed compiler error in SVGImageView related to use of LAYER_TYPE_SOFTWARE.

Thanks for the report!  This fix will be in the next release.

Original comment by paul.leb...@gmail.com on 31 Oct 2013 at 5:45

GoogleCodeExporter commented 9 years ago
This fix is available in the 1.2.1 release.

Original comment by paul.leb...@gmail.com on 31 Jan 2014 at 1:32