JoanZapata / android-iconify

Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
http://joanzapata.com/android-iconify
Other
3.93k stars 526 forks source link

Exception while Running #59

Closed tkrause closed 9 years ago

tkrause commented 9 years ago

I've been working on an application that uses android-iconify recently and was using IconButton and IconTextView which worked a few days ago. I noticed a new commit was made 2 hours ago and I believe is the cause of the issue. It looks like the Font was moved but the name was not updated and causes the following exception.

10-21 18:06:49.410 1741-1741/net.codesector.Mileage E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: net.codesector.Mileage, PID: 1741 java.lang.RuntimeException: Unable to start activity ComponentInfo{net.codesector.Mileage/net.codesector.Mileage.LoginActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.IconTextView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.IconTextView at android.view.LayoutInflater.createView(LayoutInflater.java:621) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697) at android.view.LayoutInflater.rInflate(LayoutInflater.java:756) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290) at android.app.Activity.setContentView(Activity.java:1929) at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:595)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)             at android.view.LayoutInflater.inflate(LayoutInflater.java:492)             at android.view.LayoutInflater.inflate(LayoutInflater.java:397)             at android.view.LayoutInflater.inflate(LayoutInflater.java:353)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)             at android.app.Activity.setContentView(Activity.java:1929)             at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14)             at android.app.Activity.performCreate(Activity.java:5231)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: native typeface cannot be made at android.graphics.Typeface.(Typeface.java:175) at android.graphics.Typeface.createFromFile(Typeface.java:159) at com.joanzapata.android.iconify.Iconify.getTypeface(Iconify.java:80) at com.joanzapata.android.iconify.Iconify.addIcons(Iconify.java:53) at android.widget.IconTextView.init(IconTextView.java:46) at android.widget.IconTextView.(IconTextView.java:36)             at java.lang.reflect.Constructor.constructNative(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:423)             at android.view.LayoutInflater.createView(LayoutInflater.java:595)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)             at android.view.LayoutInflater.inflate(LayoutInflater.java:492)             at android.view.LayoutInflater.inflate(LayoutInflater.java:397)             at android.view.LayoutInflater.inflate(LayoutInflater.java:353)             at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)             at android.app.Activity.setContentView(Activity.java:1929)             at net.codesector.Mileage.LoginActivity.onCreate(LoginActivity.java:14)             at android.app.Activity.performCreate(Activity.java:5231)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method)

tkrause commented 9 years ago

Forgot to mention, I am using Gradle with the following in my build.gradle in the app folder.

android { compileSdkVersion 19 buildToolsVersion '20.0.0'

defaultConfig {
    applicationId "net.codesector.Mileage"
    minSdkVersion 15
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

} dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.joanzapata.android:android-iconify:1.0.6' }

mikepenz commented 9 years ago

@tkrause the newest commit shouldn't cause this issue because it won't update the version which is deployed at maven. I see you still use the version 1.0.6.

Have you updated build-tools, android studio, or something like this?

tkrause commented 9 years ago

Yes I did update Android Studio to the 0.8.6 release recently could be the cause of the issue I am using build tools version 20.0.0 as well.

mikepenz commented 9 years ago

So i think this is the cause. Try to update to the latest versions of both, perhaps they fix it for you

tkrause commented 9 years ago

Updated to build tools 21.0.2 (newest version) as well as Android Studio 0.8.9 (newest version) still receiving the same error it is unable to find the typeface file. Must be a problem with the code which loads the typeface.

mikepenz commented 9 years ago

Interesting. There's a seperate pull-request which handles the location of the typeface file: https://github.com/JoanZapata/android-iconify/pull/58

can you try if this fixes your issue?

tkrause commented 9 years ago

That pull request works however you have to put the typeface file into the /src/main/assets folder of your actual project instead of keeping it in the compiled JAR file which obviously is preferred but it's better than it not working at all so for now I'll just use that.

mikepenz commented 9 years ago

tried the pull request. but if i place the font into /src/main/assets it won't show any icons

tkrause commented 9 years ago

Well the pull request changes the path to be the context of the view. So you need to put the font into /src/main/assets of the project your using android-iconify on.

mikepenz commented 9 years ago

@tkrause tried it with the sample app.

so we can't merge it if the user would have to add the font to his project.

tkrause commented 9 years ago

Yes I understand that and it makes no sense to merge it. However, it fixes it for me and I'm fine with putting the font in my directory in order to get it to work. But I will happily try other things if you have any ideas.

dchatry commented 9 years ago

Got the exact same issue here with the latest version of Android Studio/Build tools. Is there any fix yet ? (other than using the pull request and putting the font in assets)

mikepenz commented 9 years ago

@rivals not really. This pull request requires the dev to include the font within his app which is not a good idea.

artemtkachenko commented 9 years ago

Got the same issue. Replace "IconTextView" with "android.widget.IconTextView" in xml layout.

And it works fine.

ghost commented 9 years ago

I'm using the 1.0.9 version of the library and replacing "IconTextView" with "android.widget.IconTextView" in my xml layouts as @artemtkachenko suggested fixed the problem for me.

mikepenz commented 9 years ago

@k3v1n4ud3 ok thanks

MatthewBooth commented 9 years ago

This is still a problem when running the emulator. Works fine on my device, but in the emulator this error is thrown all the time. If #58 doesn't break anything,. I see no reason not to have merged it, if it fixed this issue.

JoanZapata commented 9 years ago

58 breaks retrocompat.

Anyway, just wait for Iconify 2.0.0, it'll fix this issue definitely. Should be available soon.