0

I am new in android studio. I used Fbutton pakage for style to Buttons. My App stoped in first when I updated android studio.I checked logcat and saw below error.

11-02 17:16:56.170 3195-3195/com.example.zfarzaneh.fitnessyoga E/AndroidRuntime: FATAL EXCEPTION: main
                                                                             Process: com.example.zfarzaneh.fitnessyoga, PID: 3195
                                                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.zfarzaneh.fitnessyoga/com.example.zfarzaneh.fitnessyoga.MainActivity}: android.view.InflateException: Binary XML file line #31: Binary XML file line #31: Error inflating class info.hoang8f.widget.FButton
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:148)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                 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 #31: Binary XML file line #31: Error inflating class info.hoang8f.widget.FButton
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                                                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                                 at com.example.zfarzaneh.fitnessyoga.MainActivity.onCreate(MainActivity.java:14)
                                                                                 at android.app.Activity.performCreate(Activity.java:6237)
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:148) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                 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 #31: Error inflating class info.hoang8f.widget.FButton
                                                                                 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.rInflate(LayoutInflater.java:838)
                                                                                 at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                 at com.example.zfarzaneh.fitnessyoga.MainActivity.onCreate(MainActivity.java:14) 
                                                                                 at android.app.Activity.performCreate(Activity.java:6237) 
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:148) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                 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: java.lang.reflect.InvocationTargetException
                                                                                 at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:619)
                                                                                 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.rInflate(LayoutInflater.java:838) 
                                                                                 at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                 at com.example.zfarzaneh.fitnessyoga.MainActivity.onCreate(MainActivity.java:14) 
                                                                                 at android.app.Activity.performCreate(Activity.java:6237) 
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:148) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                 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: java.lang.UnsupportedOperationException: Can't convert to color: type=0x5
                                                                                 at android.content.res.TypedArray.getColor(TypedArray.java:451)
                                                                                 at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
                                                                                 at info.hoang8f.widget.FButton.<init>(FButton.java:52)
                                                                                 at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
                                                                                 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.rInflate(LayoutInflater.java:838) 
                                                                                 at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                                                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
                                                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284) 
                                                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                                 at com.example.zfarzaneh.fitnessyoga.MainActivity.onCreate(MainActivity.java:14) 
                                                                                 at android.app.Activity.performCreate(Activity.java:6237) 
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) 
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                                 at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                 at android.os.Looper.loop(Looper.java:148) 
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                 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) 

So I googling And find this question. But when I change gradle version I got below error .So I set the settings to the first.

Error:(22, 0) Could not find method implementation() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. <a href="openFile:C:\Users\zfarzaneh\AndroidStudioProjects\yogafitness4\app\build.gradle">Open File</a>

Befor updated visual studio I used lasted version of gradle And I don't have any problem with Fbutton pakage. How Can I fix it?

Edit As @TokajiP sad I changed implementation to compile like this:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

compile 'com.android.support:cardview-v7:26.1.0'
compile 'info.hoang8f:fbutton:1.0.5'
// compile 'com.iangclifton.android:floatlabel:1.0.4'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testcompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
}

But I get below Error.

Error:(30, 0) Could not get unknown property 'compile' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.<a href="openFile:C:\Users\zfarzaneh\AndroidStudioProjects\fitnessYoga3\app\build.gradle">Open File</a>

Why? How Fix it?

Abolfazl R
  • 41
  • 8
zeynab farzaneh
  • 529
  • 4
  • 20

2 Answers2

1

When you set the Gradle plugin to 2.3.3 you won't have the implementation dependency adding keyword.
You need to change the implementation to compile in your app build.gradle file.

Here you can find more details about the migration from 2.3.3 to 3.0.0: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

TokajiP
  • 36
  • 3
  • If `test compile 'junit:junit:4.12'` is the 30th row, you need `testCompile` and it's `androidTestCompile` in the next row. – TokajiP Nov 02 '17 at 15:42
0

This will be the easiest fix. You don't need the whole library at all. It's a single java class.So you can do it like this.

Just copy this java class named

FButton.java

in

src/main/java/

https://github.com/hoang8f/android-flat-button/tree/master/library/src/main/java/info/hoang8f/widget

and just copy values in

https://github.com/hoang8f/android-flat-button/tree/master/library/src/main/res/values

res/values/attrs.xml
res/values/colors.xml
res/values/dimens.xml

and merge with your attrs.xml,colors.xml and dimens.xml .If these folders are not present just copy them. Note: please don't replace them. Also remove this compile 'info.hoang8f:fbutton:1.0.5 after doing all these steps and you have to remove info.hoang8f.widget.FButton from the xml and replace it with the new Fbutton you copied.

Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53