Why am I getting java.lang.NoClassDefFoundError when calling getDrawable? - android

I am trying to change the icon on a button inside a ListView at runtime, but when my code has calls to getDrawable, e.g.
getDrawable(android.R.drawable.ic_media_pause)
I get java.lang.NoClassDefFoundError from inside the activity's onCreate method. When I remove calls to getDrawable, the app runs fine.
01-29 18:31:43.526 30890-30890/com.p403n1x87.motee E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.p403n1x87.motee, PID: 30890
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/p403n1x87/motee/device/DeviceActivity$onCreate$adapter$1$1;
at com.p403n1x87.motee.device.DeviceActivity.onCreate(DeviceActivity.kt:40)
at android.app.Activity.performCreate(Activity.java:6251)
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.ClassNotFoundException: Didn't find class "com.p403n1x87.motee.device.DeviceActivity$onCreate$adapter$1$1" on path: DexPathList[[zip file "/data/app/com.p403n1x87.motee-1/base.apk"],nativeLibraryDirectories=[/data/app/com.p403n1x87.motee-1/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)
at com.p403n1x87.motee.device.DeviceActivity.onCreate(DeviceActivity.kt:40) 
at android.app.Activity.performCreate(Activity.java:6251) 
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) 
Suppressed: java.lang.ClassNotFoundException: com.p403n1x87.motee.device.DeviceActivity$onCreate$adapter$1$1
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)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

After seeing the same error when trying to get the intent from the activity inside an anonymous class instance, I realised that I should have explicitly requested the method from it, i.e. it.getDrawable. Given that the build process completes successfully, this looks like a Kotlin bug to me.

Related

Hardcoded app:fragment string in Preference crashes in Release

Below is the simplified version of the xml file for my settings screen.
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--hardcoded app:fragment crashes in release because of ClassNameNotFound -->
<Preference
app:allowDividerAbove="true"
app:fragment="com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences"
app:icon="#drawable/ic_delete_settings_24dp"
app:title="Clear data" />
</androidx.preference.PreferenceScreen>
It works well in debug version. But when I click on the preference on release apk, it crashes because of ClassNotFoundException.
Stacktrace here
Process: com.flamyoad.tsukiviewer, PID: 13647
androidx.fragment.app.Fragment$c: Unable to instantiate fragment com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences: make sure class name exists
at i.l.d.n.d()
at androidx.fragment.app.Fragment.a()
at i.l.d.r$c.a(:2)
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2)
at i.s.f.b(:29)
at androidx.preference.Preference.a(:23)
at androidx.preference.Preference$a.onClick()
at android.view.View.performClick(View.java:4757)
at android.view.View$PerformClick.run(View.java:19769)
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:5289)
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.ClassNotFoundException: com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at i.l.d.n.c(:2)
at i.l.d.n.d() 
at androidx.fragment.app.Fragment.a() 
at i.l.d.r$c.a(:2) 
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2) 
at i.s.f.b(:29) 
at androidx.preference.Preference.a(:23) 
at androidx.preference.Preference$a.onClick() 
at android.view.View.performClick(View.java:4757) 
at android.view.View$PerformClick.run(View.java:19769) 
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:5289) 
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.ClassNotFoundException: Didn't find class "com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences" on path: DexPathList[[zip file "/data/app/com.flamyoad.tsukiviewer-1/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
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 java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:308) 
at i.l.d.n.c(:2) 
at i.l.d.n.d() 
at androidx.fragment.app.Fragment.a() 
at i.l.d.r$c.a(:2) 
at com.flamyoad.tsukiviewer.ui.settings.SettingsActivity.a(:2) 
at i.s.f.b(:29) 
at androidx.preference.Preference.a(:23) 
at androidx.preference.Preference$a.onClick() 
at android.view.View.performClick(View.java:4757) 
at android.view.View$PerformClick.run(View.java:19769) 
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:5289) 
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) 
Suppressed: java.lang.ClassNotFoundException: com.flamyoad.tsukiviewer.ui.settings.preferences.ClearDataPreferences
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)
... 21 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
To me, it looks like the cause is the apk being minified and class name is replaced with shorter string. What can I do in this situation? Is it best practice to replace the app:fragment with function calls in Activity? Or is there any other methods?
I'm using PreferenceFragmentCompat for my application.
The aapt2 generated proguard rules for preferences specifically look for the android:fragment attribute, not app:fragment. You'd want to use android:fragment to automatically keep preference fragments.
I added these lines into my proguard-rules.pro and it stopped crashing.
-keep public class * extends androidx.preference.Preference
-keep public class * extends androidx.preference.PreferenceFragmentCompat

ClassNotFoundException when starting any new activity

When I try to start any activity beside MainActivity in application, I experience a crash in some devices.
as I can see in crashAnalytics it does not depend on the version or brand of the device or android version,
fatal exception don't refers to any line in my project.
already tried to delete .gradle folder / clear project, does not work.
03-30 19:13:46.458 7597-7597/ru.sberleasing E/AndroidRuntime: FATAL EXCEPTION: main
Process: ru.sberleasing, PID: 7597
java.lang.NoClassDefFoundError: java.lang.invoke.SerializedLambda
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
at java.lang.Class.getDexCacheType(Class.java:476)
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:166)
at java.lang.reflect.Method.getParameterTypes(Method.java:170)
at java.lang.Class.getDeclaredMethods(Class.java:673)
at java.io.ObjectStreamClass.computeSerialVersionUID(ObjectStreamClass.java:566)
at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:279)
at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1087)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:1055)
at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:268)
at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1087)
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1554)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461)
at android.os.Parcel.writeSerializable(Parcel.java:1442)
at android.os.Parcel.writeValue(Parcel.java:1395)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
at android.os.Bundle.writeToParcel(Bundle.java:1079)
at android.os.Parcel.writeBundle(Parcel.java:690)
at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:167)
at android.os.Parcel.writeTypedList(Parcel.java:1148)
at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:51)
at android.os.Parcel.writeParcelable(Parcel.java:1416)
at android.os.Parcel.writeValue(Parcel.java:1322)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:665)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330)
at android.os.Bundle.writeToParcel(Bundle.java:1079)
at android.os.Parcel.writeBundle(Parcel.java:690)
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417)
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: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.ClassNotFoundException: Didn't find class "java.lang.invoke.SerializedLambda" on path: DexPathList[[zip file "/data/app/ru.sberleasing-2/base.apk"],nativeLibraryDirectories=[/data/app/ru.sberleasing-2/lib/x86, /data/app/ru.sberleasing-2/base.apk!/lib/x86, /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 libcore.reflect.InternalNames.getClass(InternalNames.java:53)
at java.lang.Class.getDexCacheType(Class.java:476) 
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:166) 
at java.lang.reflect.Method.getParameterTypes(Method.java:170) 
at java.lang.Class.getDeclaredMethods(Class.java:673) 
at java.io.ObjectStreamClass.computeSerialVersionUID(ObjectStreamClass.java:566) 
at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:279) 
at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1087) 
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:1055) 
at java.io.ObjectStreamClass.createClassDesc(ObjectStreamClass.java:268) 
at java.io.ObjectStreamClass.lookupStreamClass(ObjectStreamClass.java:1087) 
at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1554) 
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) 
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) 
at android.os.Parcel.writeSerializable(Parcel.java:1442) 
at android.os.Parcel.writeValue(Parcel.java:1395) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
at android.os.Bundle.writeToParcel(Bundle.java:1079) 
at android.os.Parcel.writeBundle(Parcel.java:690) 
at androidx.fragment.app.FragmentState.writeToParcel(FragmentState.java:167) 
at android.os.Parcel.writeTypedList(Parcel.java:1148) 
at androidx.fragment.app.FragmentManagerState.writeToParcel(FragmentManagerState.java:51) 
at android.os.Parcel.writeParcelable(Parcel.java:1416) 
at android.os.Parcel.writeValue(Parcel.java:1322) 
at android.os.Parcel.writeArrayMapInternal(Parcel.java:665) 
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1330) 
at android.os.Bundle.writeToParcel(Bundle.java:1079) 
at android.os.Parcel.writeBundle(Parcel.java:690) 
at android.app.ActivityManagerProxy.activityStopped(ActivityManagerNative.java:3152) 
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3417) 
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: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) 
Suppressed: java.lang.ClassNotFoundException: java.lang.invoke.SerializedLambda
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)
... 39 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
in my case problem was in Compile version.
probably voximplant-sdk conflicts with api 29, version downgrading solved the problem for now.

"React Native with Android aar library" ClassNotFoundException: kotlin.LazyKt

I’m using my own Android library that done on Kotlin.
I build that library into the *.aar file and import in separate project on React Native.
The crash appears in Android React Native app when I start Service from that library, where some field initialized by lazy way.
I could not find an error similar to "Lkotlin / LazyKt" or "kotlin.LazyKt". Maybe someone faced a similar problem? I would be grateful for any tip.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.project_mobile:sdmp, PID: 18913
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/LazyKt;
at com.project.service.SdmService.<init>(SdmService.kt:27)
at java.lang.Class.newInstance(Native Method)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
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.ClassNotFoundException: Didn't find class "kotlin.LazyKt" on path: DexPathList[[zip file "/data/app/com.project_mobile-2/base.apk"],nativeLibraryDirectories=[/data/app/com.project_mobile-2/lib/arm, /data/app/com.project_mobile-2/base.apk!/lib/armeabi-v7a, /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 com.project.service.SdmService.<init>(SdmService.kt:27) 
at java.lang.Class.newInstance(Native Method) 
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2859) 
at android.app.ActivityThread.-wrap4(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) 
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) 
Suppressed: java.lang.ClassNotFoundException: kotlin.LazyKt
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)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Android - ResourceNotFoundException and NumberFormatException

I have created an app in which I've used android.support.v4.widget.DrawerLayout along with android.support.v7.widget.Toolbar.
When I run this app on a Samsung Tablet Neo (Android version 4.2.2), the app is running perfectly.
But when I run the same app on Google Nexus 5 (Android version 6.0.1), I'm getting ResourceNotFoundException and the app just crashes on the starting line of the following code in my Java (Activity) file.
The app crashes on this line: setSupportActionBar(topToolBar);
FATAL EXCEPTION: main
rocess: com.myapp, PID: 11761
va.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivityWithNavigationViewExpandableList}: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c00ab
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)
aused by: android.content.res.Resources$NotFoundException: File res/color/abc_hint_foreground_material_dark.xml from color state list resource ID #0x7f0c00ab
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2750)
at android.content.res.Resources.loadColorStateList(Resources.java:2699)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:485)
at android.widget.TextView.<init>(TextView.java:746)
at android.widget.TextView.<init>(TextView.java:671)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54)
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756)
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:78)
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:223)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130)
at com.myapp.MainActivityWithNavigationViewExpandableList.onCreate(MainActivityWithNavigationViewExpandableList.java:64)
at android.app.Activity.performCreate(Activity.java:6251)
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) 
aused by: java.lang.NumberFormatException: Invalid float: "0.70000005dip"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseFloat(StringToReal.java:323)
at java.lang.Float.parseFloat(Float.java:306)
at android.content.res.TypedArray.getFloat(TypedArray.java:396)
at android.content.res.ColorStateList.inflate(ColorStateList.java:275)
at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:222)
at android.content.res.ColorStateList.createFromXml(ColorStateList.java:201)
at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2746)
at android.content.res.Resources.loadColorStateList(Resources.java:2699) 
at android.content.res.TypedArray.getColorStateList(TypedArray.java:485) 
at android.widget.TextView.<init>(TextView.java:746) 
at android.widget.TextView.<init>(TextView.java:671) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58) 
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:54) 
at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:756) 
at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261) 
at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243) 
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:78) 
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:223) 
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:130) 
at com.myapp.MainActivityWithNavigationViewExpandableList.onCreate(MainActivityWithNavigationViewExpandableList.java:64) 
at android.app.Activity.performCreate(Activity.java:6251) 
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) 
I searched other SO answers as well.
The resource 'abc_hint_foreground_material_dark' is not in my 'color'. This resource should come from Support Library of Android, which I'm using in Android Studio.
abc_hint_foreground_material_dark is a link to the theme's foreground_material_dark, see here.
The NumberFormatException says that this color value is invalid ('Invalid float: "0.70000005dip"'). This value does not come from support library so must have been set by your resources (check colors.xml and values.xml). Color values should be hex integers and are not in dp or any other unit. See here for more info.
So finally I digged more in the issue and my suspect was NumberFormatException. I searched for decimal values in my dimens.xml file and commented them. And it worked fine now. Basically, Android was unable to parse the decimal values placed in dimens.xml file.

Unity cannot sync gradle of android project

I compiled okttp in my gradle file, I can call OKHTTP object in my activity. But when I make aar file and import it into Unity Project -> build APK file and run -> app was crashed. I tried many orther library but it's same error.
This is Log:
06-13 16:35:10.610 32314-32314/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: jp.tsutayamovie, PID: 32314
java.lang.Error: FATAL EXCEPTION [main]
Unity version : 5.4.4f1
Device model : LGE Nexus 5
Device fingerprint: google/hammerhead/hammerhead:6.0.1/M4B30Z/3437181:user/release-keys
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/OkHttpClient;
at com.jlabs.pluginplayer.PlayerActivity.onCreate(PlayerActivity.java:288)
at android.app.Activity.performCreate(Activity.java:6251)
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.ClassNotFoundException: Didn’t find class “okhttp3.OkHttpClient” on path: DexPathList[[zip file “/data/app/jp.tsutayamovie-1/base.apk”],nativeLibraryDirectories=[/data/app/jp.tsutayamovie-1/lib/arm, /data/app/jp.tsutayamovie-1/base.apk!/lib/armeabi-v7a, /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 com.jlabs.pluginplayer.PlayerActivity.onCreate(PlayerActivity.java:288) 
at android.app.Activity.performCreate(Activity.java:6251) 
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) 
Suppressed: java.lang.ClassNotFoundException: okhttp3.OkHttpClient
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)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Everybody know why? how I can fixed?

Categories

Resources