I'm developing an app which is requires google fingerprint auth for login my app. My app Requires Android 4.4 and up (api level >19), but fingerprint auth added in api level 23 onwards. is it possible to make my app support fingerprint auth with the api level I mentioned 19.
In my gradle I make minsdk as 19 when I put 19 it crashes and give below error. but when I change to 23 it's fine.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: info.androidhive.fingerprint, PID: 15697
java.lang.NoClassDefFoundError: Failed resolution of:
Landroid/hardware/fingerprint/FingerprintManager;
at info.androidhive.fingerprint.FingerprintActivity.onCreate(FingerprintActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.hardware.fingerprint.FingerprintManager" on path: DexPathList[[zip file "/data/app/info.androidhive.fingerprint-1/base.apk"],nativeLibraryDirectories=[/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)
at info.androidhive.fingerprint.FingerprintActivity.onCreate(FingerprintActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6010)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Suppressed: java.lang.ClassNotFoundException: android.hardware.fingerprint.FingerprintManager
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)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
We cannot use FingerpintManager with api less than 23. The minSdkVersion for this FingerpintManager is 23.
If you want to use FingerpintManager in apps whose API level is less than 23, you may consider using FingerprintManagerCompat, which behaves as if no fingerprint sensors are available with API level less than 23.
For more info check link and also example.
https://developer.android.com/reference/android/support/v4/hardware/fingerprint/FingerprintManagerCompat.html
https://github.com/AMykich/Android-Fingerprint-API
Every time Instant Run applied code changes and restart an activity containing a GooglePlusOne button the app crashes with the following exception:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.myapp, PID: 26877
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myapp/com.mycompany.activities.MyActivity}: android.view.InflateException: Binary XML file line #221: Error inflating class <unknown>
...
Caused by: android.view.InflateException: Binary XML file line #221: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
...
...
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1266)
at android.content.res.Resources.getDrawable(Resources.java:785)
at android.content.res.Resources.getDrawable(Resources.java:752)
at com.google.android.gms.plus.PlusOneDummyView$zzb.getDrawable(Unknown Source)
at com.google.android.gms.plus.PlusOneDummyView.<init>(Unknown Source)
at com.google.android.gms.plus.internal.zzg.zza(Unknown Source)
at com.google.android.gms.plus.PlusOneButton.zzca(Unknown Source)
at com.google.android.gms.plus.PlusOneButton.<init>(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.mycompany.MyActivity.inializeContents(MyActivity.java:37)
...
...
I do not know where to fill a bug report for Google Play Services, hoping the Google team look at StackOverflow.
And is there any workaround to make Instant Run works even in this such case?
Note: I'm using Android Studio 2.2 and Google Play Services 9.6.0 but this problem also occurred on previous versions.
My CollapsingToolbarLayout crashes because of Error inflating class android.support.design.widget.CollapsingToolbarLayout.
I updated the android studio last weekend. Before the updated, it works fine. After I updated it, it crashed. However, I tried to downgrade it to 2.0.0 version and it's not working anymore. My coworker has no problem with the CollapsingToolbarLayout. I am not sure what happened.
The error was:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.android/com.test.android.ui.activity.RandomActivity}: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat; or its super classes (declaration of 'android.support.v4.graphics.drawable.DrawableCompat' appears in /data/app/com.test.android-1/base.apk)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:197)
at android.support.design.widget.CollapsingToolbarLayout.<init>(CollapsingToolbarLayout.java:132)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.test.android.ui.activity.RefreshableActivity.onCreate(RefreshableActivity.java:31)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
Here's my CollapsingToolbarLayout:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
app:contentScrim="#color/blue"
app:statusBarScrim="#color/blue_dark"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
>
<include layout="#layout/layout_page" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include
layout="#layout/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
/>
</android.support.design.widget.CoordinatorLayout>
Here's my gradle file:
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:customtabs:23.4.0'
compile 'com.android.support:design:23.4.0'
Do you guys have any idea? Thanks.
I found a solution May it work try it:
add below code in gradle build file
compile ('com.android.support:support-v4:23.4.0'){
force = true;
}
Seems like it is having version conflict issue. All support library must be of same version. However, I didn't use v4 support library before and it works.
I don't know why updatimg android studio to 2.1.1 causes the issue.
I just force all v4 library to the same as other support libraries.
I know there is an accepted answer already, BUT it is not working (or no longer working).
I spent a couple of hours researching on this error, what I came up was this.
First, due to initial release of Android Nougat also known as Android 7.0 (API 24) compileSdkVersion 24 is now available. To do that, you have to update your sdk. Step 1
Second, is to update your gradle files (internet connection required). Step 2
Also Update this part of app.gradle
Third (optional) Clean Project, Build Project (Both under Build Tab)
I hope this helped someone out there and save some few hours of researching.
Cheers / Happy coding
i found two solutions,
first one is
app:statusBarScrim="#null"
second is to force app
compile ('com.android.support:support-v4:23.4.0') {
force = true;
}
Sources taken from here
I had the same issue, #Shumin's code is effective too but it is better to remove conflicts instead of bypassing them. To find the conflict -
In Android Studio, open Terminal and enter gradlew app:dependencies.
Check the dependencies tree and see which library is causing conflict
Update:-
To check for conflicts, check the dependencies of each library and see if you aren't using the same dependency in some other library but with different version. For example, in the image below, com.android.support:appcompat-v7 is dependent on com.android.support:support-vector-drawable:23.4.0. If you find some other library depending on com.android.support:support-vector-drawable but the version is different, then you have found your conflict.
My issue was that not all of the support library gradle imports we the same, eg, I had:
compile('com.android.support:recyclerview-v7:23.4.0') {
exclude module: 'support-v4'
}
compile 'com.android.support:support-annotations:24.0.0'
changing it so all imports were 24.0.0 enabled the application to run without issues.
Hello Friend i face this issue
Just Make
compileSdkVersion 25
buildToolsVersion "25.0.2"
And All support gradle change to 25.1.1 it's work for me .
please add below code in menifiest.xml.
<activity android:name=".MainActivity"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and style resource file
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
I had the same issue showing the same error while inflating the CollapsingToolbar..
I had the following dependencies in my app gradle file
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
and build tool 25.0.2 with compiled with API 23 sdk.
I than checked the dependencies and found that firebase uses
android:support:support-v4:24.0.0
and the appcompat uses
android:support:support-v4-23.4.0 -> 24.0
Hence, I changed all the build library number to
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.google.firebase:firebase-ads:10.0.1'
It worked for me now. How durable ? I don't have any idea.
This worked for me. Change you your appcompact and design libray version as follows,
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
If you are working on Oreo or upper sdk and using a drawable in CollapsingToolbar, check this drawable exists in normal drawable folder and drawable-v24 folder.
If your drawable is only in drawable-v24 folder and running the app under Oreo sdk, Android Studio logcat says "crash in CollapsingToolbar" but real problem is missing some drawables in your drawable folder.
I have switched my Android development over to Kotlin, but I am dealing with a crash that I can't figure out. I am used to, in Java, being able to display an error on an empty EditText:
if(mEmail.getText().toString().isEmpty()) {
mEmail.setError("Email cannot be blank.");
}
To the best of my knowledge, that could be translated to Kotlin as:
if(email.text.toString().isEmpty()) {
email.error = "Email cannot be blank."
}
However, that doesn't work, and I get the following stack trace:
Process: com.androidessence.capturethetag, PID: 4016
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor.showError(Editor.java:319)
at android.widget.Editor.setError(Editor.java:355)
at android.widget.TextView.setError(TextView.java:4648)
at android.widget.TextView.setError(TextView.java:4633)
at com.androidessence.capturethetag.activities.LoginActivity.validateInput(LoginActivity.kt:31)
at com.androidessence.capturethetag.activities.LoginActivity.access$validateInput(LoginActivity.kt:12)
at com.androidessence.capturethetag.activities.LoginActivity$onCreate$1.onClick(LoginActivity.kt:19)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 24
at android.content.res.TypedArray.getColor(TypedArray.java:401)
at android.widget.TextView.<init>(TextView.java:696)
at android.widget.TextView.<init>(TextView.java:632)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:92)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor.showError(Editor.java:319)
at android.widget.Editor.setError(Editor.java:355)
at android.widget.TextView.setError(TextView.java:4648)
at android.widget.TextView.setError(TextView.java:4633)
at com.androidessence.capturethetag.activities.LoginActivity.validateInput(LoginActivity.kt:31)
at com.androidessence.capturethetag.activities.LoginActivity.access$validateInput(LoginActivity.kt:12)
at com.androidessence.capturethetag.activities.LoginActivity$onCreate$1.onClick(LoginActivity.kt:19)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Any ideas why this is crashing in Kotlin?
EDIT
For more information, you can see my content_login.xml file here. I've used Gist to save space.
Also, I never call findViewById(); on my EditText because the Kotlin-Android Extension Plugin can do it, as mentioned here: https://kotlinlang.org/docs/tutorials/android-plugin.html
I have no doubts that it's referencing the right EditText, because logging showed me that it was able to determine the EditText was empty, but is unable to set the error attribute.
I'm trying to upgrade my app from API19 to API21
The main changes I've made to the gradle properties are:
compileSdkVersion 21
buildToolsVersion "21.0.2"
minSdkVersion 8
targetSdkVersion 21
compile 'com.android.support:appcompat-v7:21.0.0'
The app builds ok, but I always get the following error:
10-22 23:10:38.867 7972-8058/com.example.android.demo E/ACRA? com.example.android.demo fatal error : Unable to start activity ComponentInfo{com.example.android.demo/com.example.android.demo.MainActivity2}: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.v7.internal.widget.ActionBarContainer
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.demo/com.example.android.demo.MainActivity2}: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.v7.internal.widget.ActionBarContainer
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #27: Error inflating class android.support.v7.internal.widget.ActionBarContainer
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:273)
at android.support.v7.app.ActionBarActivityDelegateBase.createSupportActionBar(ActionBarActivityDelegateBase.java:155)
at android.support.v7.app.ActionBarActivityDelegate.getSupportActionBar(ActionBarActivityDelegate.java:123)
at android.support.v7.app.ActionBarActivity.getSupportActionBar(ActionBarActivity.java:73)
at com.example.android.demo.MainActivity2.onCreate(MainActivity2.java:243)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:273)
at android.support.v7.app.ActionBarActivityDelegateBase.createSupportActionBar(ActionBarActivityDelegateBase.java:155)
at android.support.v7.app.ActionBarActivityDelegate.getSupportActionBar(ActionBarActivityDelegate.java:123)
at android.support.v7.app.ActionBarActivity.getSupportActionBar(ActionBarActivity.java:73)
at com.example.android.demo.MainActivity2.onCreate(MainActivity2.java:243)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 11
at android.content.res.TypedArray.getDrawable(TypedArray.java:747)
at android.support.v7.internal.widget.ActionBarContainer.<init>(ActionBarContainer.java:66)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.ActionBarActivityDelegateBase.ensureSubDecor(ActionBarActivityDelegateBase.java:273)
at android.support.v7.app.ActionBarActivityDelegateBase.createSupportActionBar(ActionBarActivityDelegateBase.java:155)
at android.support.v7.app.ActionBarActivityDelegate.getSupportActionBar(ActionBarActivityDelegate.java:123)
at android.support.v7.app.ActionBarActivity.getSupportActionBar(ActionBarActivity.java:73)
at com.example.android.demo.MainActivity2.onCreate(MainActivity2.java:243)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I've tried the version 4 (which I was using previously) and the v7 ActionBarDrawerToggle (with a change to the new format for the constructor) but always get the same error. The apps theme is a parent of Theme.AppCompat.Light.DarkActionBar
I'm not really sure what to look at.
I had the same problem when trying to use ?attr/selectableItemBackground and based on your answer and some digging around on the internet I found out what was wrong for me (and probably you as well).
From this answer I learned that "? mark is used to reference style in current theme." Which means that when you use ?attr/ you refer to something in the current theme.
I noticed that I got this crash only when inflating using the application context and not when using the activity context. This blog post explains what's happening in "Context Capabilities" section.
...[When using the application context] inflation will be done with
the default theme for the system on which you are running, not what’s
defined in your application.
This mean that ?attr/ won't work since they refer to the current theme, not the default system theme you're inflating with.
So ?attr/ works fine if you make sure to inflate using the Activity context instead of the application context.
I had similar issue, i'm using AppCompat.v21 and supporting Android 5.0.
My layout uses the ?attr/[attribute_name] for some values and I use the activity context.
I changed it to ?android:attr/[attribute_name] and now my views inflate just fine on devices running Android 5.0.
For me the issue seemed to be in layout files when using the ?attr/ format for values. I'm not sure if it's theme related. I took all these out to get things going and then added styles back in.
style name="AppTheme" parent="Base.V23.Theme.AppCompat"
in style.xml worked for my app.