Closed alensiljak closed 8 years ago
This will work once I get a proper aar build working.
You could try copying the AndroidSVG res/values/attrs.xml
into your own res/values
directory. Or merge the contents if you already have an attrs.xml
.
No worries. I'll keep the sources as the part of the build instead of fetching the library through Maven repository. It works that way. I might try this approach later just because it is "cleaner" and more convenient to update at a later date. I've just compared the sources and the version I have (from google code) is the same as the current one here. Glad to see that the repo has moved to GitHub. I also wanted to say that I'm using AndroidSVG in http://android.moneymanagerex.org/. You can see it in action at the very first screen (short overview/tutorial) at http://android.moneymanagerex.org/appDemo.html. :) I'm also hoping to replace all the graphics either with SVGs or font-icons (which is more-or-less the same thing). Would be nice to merge the two together as both approaches have their pros & cons. The library I used for font icons is https://github.com/shamanland/fonticon. The (only?) benefit of icon fonts is that all the graphics are stored together in a font file. However, using AndroidSVG is much more natural as I'm working with image view, so centering & resizing works better than calculating the font sizes.
Great. I love hearing about how AndroidSVG is being used. Thanks for letting me know.
On 20 October 2015 at 02:17, Alen Siljak notifications@github.com wrote:
No worries. I'll keep the sources as the part of the build instead of fetching the library through Maven repository. It works that way. I might try this approach later just because it is "cleaner" and more convenient to update. I've just compared the sources and the version I have (from google code) is the same as the current one here. Glad to see that the repo has moved to GitHub. I also wanted to say that I'm using AndroidSVG in http://android.moneymanagerex.org/. You can see it in action at the very first screen (short overview/tutorial) at http://android.moneymanagerex.org/appDemo.html. :) I'm also hoping to replace all the graphics either with SVGs or font-icons (which is more-or-less the same thing). Would be nice to merge the two together as both approaches have their pros & cons. The library I used for font icons is https://github.com/shamanland/fonticon. The (only?) benefit of icon fonts is that all the graphics are stored together in a font file. However, using AndroidSVG is much more natural as I'm working with image view, so centering & resizing works better than calculating the font sizes.
— Reply to this email directly or view it on GitHub https://github.com/BigBadaboom/androidsvg/issues/73#issuecomment-149210629 .
Just tried following your recommendation in order to use .jar (or gradle) distribution with Xamarin app but got the exception below. Any hints would be much appreciated.
android.view.InflateException: Binary XML file line #35: Binary XML file line #35: Error inflating class com.caverock.androidsvg.SVGImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.money.manager.ex.tutorial.TutorialTransactionsFragment.onCreateView(TutorialTransactionsFragment.java:67)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:164)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1177)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1025)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1545)
at android.view.View.measure(View.java:18799)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:18799)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:898)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1458)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:746)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:18799)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2899)
at android.view.View.measure(View.java:18799)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2108)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1224)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1460)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1115)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6023)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #35: Error inflating class com.caverock.androidsvg.SVGImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
... 47 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
... 54 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/caverock/androidsvg/R$styleable;
at com.caverock.androidsvg.SVGImageView.init(SVGImageView.java:85)
at com.caverock.androidsvg.SVGImageView.<init>(SVGImageView.java:68)
... 56 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.caverock.androidsvg.R$styleable" on path: DexPathList[[zip file "/data/app/com.money.manager.ex-2/base.apk"],nativeLibraryDirectories=[/data/app/com.money.manager.ex-2/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 58 more
Suppressed: java.lang.ClassNotFoundException: com.caverock.androidsvg.R$styleable
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 59 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
It does look like a similar problem. But I'm not sure I can offer much help with Xamarin builds, as I haven't done any myself. You may have better luck asking on Stack Overflow or similar or the Xamarin forums. Sorry.
Hi, sorry for mentioning Xamarin, it has nothing to do with this issue. This is happening in the same Android app when I remove the source code of AndroidSVG, and
Xamarin is just an end goal of the exercise. But to get there, first I need to get all the libraries packaged or their source converted to C#.
And you have tried the "copy attrs.xml" suggestion?
On 11 April 2016 at 23:51, Alen Siljak notifications@github.com wrote:
Hi, sorry for mentioning Xamarin, it has nothing to do with this issue. This is happening in the same Android app when I remove the source code of AndroidSVG, and
- add either .jar file or a Gradle reference, and
- copy the content of the attrs.XML file
Xamarin is just an end goal of the exercise. But to get there, first I need to get all the libraries packaged or their source converted to C#.
— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/BigBadaboom/androidsvg/issues/73#issuecomment-208306657
Since the app already has a pretty big attrs.xml, I've simply copied the contents:
<declare-styleable name="SVGImageView">
<!-- Location of the SVG document. -->
<attr name="svg" format="reference|string"/>
</declare-styleable>
That works in a sense that there are no compile-time errors any longer. But the exception is thrown during runtime.
Ok. Can you attach the layout file that is causing the problems?
On 12 April 2016 at 01:19, Alen Siljak notifications@github.com wrote:
Since the app already has a pretty big attrs.xml, I've simply copied the contents:
— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/BigBadaboom/androidsvg/issues/73#issuecomment-208338437
Sure. This is the first one that uses the SVGViewer, where the exception happens.
Try cleaning the project maybe?
Then I would suggest searching on the "Failed resolution" error:
java.lang.NoClassDefFoundError: Failed resolution of: R$styleable;
Perhaps one of the solutions there might work? https://github.com/JakeWharton/ActionBarSherlock/issues/639 https://github.com/bauerca/drag-sort-listview/issues/105
I have this issue too. Have tried a lot of things, but nothing seemed to work. I finally imported the project as described in https://github.com/BigBadaboom/androidsvg/issues/34#issuecomment-125803252, but ofcourse it's preferable to be able to just reference the library in the maven central. I also had to remove some parts of the project, mainly the following in build.gradle
(I mainly write this if others will try the same locally, I'm pretty sure that shouldn't be done in the main project):
apply from: 'packaging_configuration.gradle'
apply from: 'upload_configuration.gradle'
dependencies {
compile 'org.jetbrains:annotations-java5:15.0'
}
Most people haven't had a problem AFAIK, so I am a bit puzzled why some of you have.
@Anigif Did you import from this repository on GitHub? The things you removed from the gradle file, shouldn't have stopped it being compiled into your app. I use:
dependencies {
compile project(':androidsvg')
}
In any case, I will try to get a 1.3 beta release built and deployed to the maven repo this weekend. I was going to put it off until I've finished working all the 1.3 milestone issues. But it makes sense to start releasing betas now. Especially if it'll help people.
Thanks for your patience.
My issue was the same as described by @MisterY, when executing my application I got a long stacktrace that incluced the message Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/caverock/androidsvg/R$styleable;
I will definintly try the 1.3 beta once you release it - looking forward to it :)
Regarding my attempt of including the project as a module (under the dependencies section as you show), I got an error when syncing my project: Error:Plugin with id 'com.github.dcendents.android-maven' not found.
. That i first resolved by removing the two apply
-lines, but I can see I could also have added classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
to my main build.gradle
-file.
After that problem I got the following when compiling:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/intellij/lang/annotations/JdkConstants$PatternFlags;
By removing the annotation-line (as described above) it compiles and seem to work.
(However... I'm not that familiar with the Gradle buildsystem, so I'm not 100% sure what I'm doing makes sense)
@Anigif, if you have time, you can have a look at MoneyManagerEx for Android code. I'm using the library referenced as a module without any issues. I'm sorry but I don't remember many details any longer. However, it works fine. You can compare to your code, for example.
@MisterY just had a look and it looks like I can compile it (with some modifications regarding a fabric key, nothing to do with this issue), but it looks like it's more or less the same as the thing I did, at least the androidSVG_12/build.gradle
-file doesn't contain any of the lines mentioned earlier (https://github.com/BigBadaboom/androidsvg/issues/73#issuecomment-365948092)
I've replaced the local copy of the sources (from google code) with the link to "compile 'com.caverock:androidsvg:1.2.1'" (or 1.2.2-beta1) and during build I'm getting the following error:
The namespace is set to
in the root LinearLayout, and the image view looks like this
Naturally, this all works when the project is compiled from source together with the main app but when I want to use the reference to a binary from Maven repository, the build errors appear. I've tried a few simple things but none of them worked. Like, removing the namespace will compile correctly but crash during runtime, etc. The main issue is that the simple replacement does not work out of the box. I will look into this a bit more when I find some time.
More info: using Android Studio with Gradle