I'm getting following exception if sometimes thought of posting it after a month. Every time I have to delete build folder and error goes away. So it is risky to stay like this condition for long run, as sometimes developer might forget to check this activity is opening or not.
So far strangely it is only happening with one file ProductListActivity.kt
This runtime error looks like common error Is there a Gradle configurations needed to fix it.
How to completely get rid of it?
java.lang.RuntimeException: Unable to start activity ComponentInfo ProductDetails.activity.ProductListActivity}: java.lang.IllegalStateException: Required view 'name_text_box' with ID 2131362920 for method 'onNearbyClicked' was not found. If this view is optional add '#Nullable' (fields) or '#Optional' (methods) annotation.
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: java.lang.IllegalStateException: Required view 'name_text_box' with ID 2131362920 for method 'onNearbyClicked' was not found. If this view is optional add '#Nullable' (fields) or '#Optional' (methods) annotation.
at butterknife.internal.Utils.findRequiredView(Utils.java:88)
at ProductDetails.activity.ProductListActivity_ViewBinding.<init>(ProductListActivity_ViewBinding.java:27)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at butterknife.ButterKnife.bind(ButterKnife.java:170)
at butterknife.ButterKnife.bind(ButterKnife.java:99)
at common.BaseActivity.setContentView(BaseActivity.java:51)
at ProductDetails.activity.ProductListActivity.onCreate(ProductListActivity.kt:220)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at and
What i can see from the logs that you are using kotlin, so instead of butterknife you can replace your code with view binding(area which are getting error)
https://kotlinlang.org/docs/tutorials/android-plugin.html
Related
when i call "realm.copyToRealmOrUpdate({RealmObject})", app crashes on lower API(21-25). No problem in version API-25 and above. Logcat output :
java.lang.IncompatibleClassChangeError: The method 'java.lang.Class java.lang.Object.getClass()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at io.realm.DefaultRealmModuleMediator.copyOrUpdate(DefaultRealmModuleMediator.java:131)
at io.realm.Realm.copyOrUpdate(Realm.java:1815)
at io.realm.Realm.copyToRealmOrUpdate(Realm.java:1199)
at com.viyatek.ultimatefacts.Activites.MainActivity.DataFetched$lambda-10(MainActivity.kt:826)
at com.viyatek.ultimatefacts.Activites.MainActivity.$r8$lambda$fX_wkxDWKFkFuw4LXNz0m5YzJyo(MainActivity.kt)
at com.viyatek.ultimatefacts.Activites.MainActivity$$ExternalSyntheticLambda4.execute(D8$$SyntheticClass)
at io.realm.Realm.executeTransaction(Realm.java:1604)
at com.viyatek.ultimatefacts.Activites.MainActivity.DataFetched(MainActivity.kt:823)
at com.viyatek.ultimatefacts.NetworkOperations.getData.ExecuteNetWorkCall$lambda-0(getData.kt:111)
at com.viyatek.ultimatefacts.NetworkOperations.getData.$r8$lambda$Va8-rJSbrmVyGMKSedsNwZR74V8(getData.kt)
at com.viyatek.ultimatefacts.NetworkOperations.getData$$ExternalSyntheticLambda1.onResponse(D8$$SyntheticClass)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:100)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
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: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 use in top-level gradle;
classpath "io.realm:realm-gradle-plugin:10.10.1"
I have no idea for the solution. I added try-catch block for now. I suspect ProGuard. but, for now i couldn't find the solution
I have an android app which compiles in AndroidStudio, but when I call a certain activity I get the following error:
11-22 16:08:40.461 13796-13796/com.impyiablue.stoxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.impyiablue.stoxx, PID: 13796
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.impyiablue.stoxx/com.impyiablue.stoxx.EditEntryActivity}: java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
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:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:606)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6422)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6591)
at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1866)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:1778)
at android.widget.LinearLayout.generateLayoutParams(LinearLayout.java:62)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:808)
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:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.impyiablue.stoxx.EditEntryActivity.onCreate(EditEntryActivity.java:51)
at android.app.Activity.performCreate(Activity.java:5977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
11-22 16:10:02.231 15805-15805/com.impyiablue.stoxx:remote E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.impyiablue.stoxx:remote, PID: 15805
java.lang.NumberFormatException: Invalid float: "N/A"
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 com.impyiablue.stoxx.Tools.ServiceStock$ResponseListener.onResponse(ServiceStock.java:86)
at com.impyiablue.stoxx.Tools.ServiceStock$ResponseListener.onResponse(ServiceStock.java:71)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
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:5272)
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:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
The corresponding xml file can be found here. I do not see any problems with this xml file. So how to fix the problem? I also did a clean before the latest build...
Look at line 25 of your XML layout, the TextView with the textTitleEdit ID is missing the layout_width and layout_height attributes, which are required. The next TextView is missing the same attributes as well.
I have an android app which compiles in AndroidStudio
Project compilation does not guarantee its correctness and this also includes layouts. Also even i.e. layout_width is mandatory for the object at runtime, lack of such during compilation is not a bug, however it is usually result of ommision/mistake. You may simply need to ommit such attributes on purpose, willing to add them later at runtime from running code. No compiler/static analyser will be able to figure this out, so that's why lint will complain, but compilation phase won't fail.
To avoid such problems you may try to use lint tool, to catch all the potential issues, however agaim, lack of given attribute is not an error therefore it will not cause any compilation errors. layout_height and layout_width are mandatory at runtime, so ViewGroup knows how to layout all the childs, and as most of your TextView's neither provide any of these directly nor indirectly, via styles your layout can be considered faulty.
I use a realm database in my android project.
I've added a new column to my realm db which I generate out of a CSV and did the same in my entity file.
However, I now get a RealmMigrationNeededException if I start my app although I have uninstalled it before. So it seems like if my generated database and the entity file don't match.
I would like to know if it's possible to find out what exactly causes the exception. The stacktrace I get in Android Studio doesn't contain any clues which might help me to resolve the issue
FATAL EXCEPTION: main
Process: de.myCompany.myApp, PID: 5270
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010 (has extras) } in de.myCompany.myApp.helper.WifiReceiver#2d683f50
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:872)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Caused by: io.realm.exceptions.RealmMigrationNeededException: RealmMigration must be provided
at io.realm.BaseRealm.migrateRealm(BaseRealm.java:589)
at io.realm.Realm.migrateRealm(Realm.java:1224)
at io.realm.Realm.migrateRealm(Realm.java:1213)
at io.realm.Realm.createInstance(Realm.java:237)
at io.realm.RealmCache.createRealmOrGetFromCache(RealmCache.java:114)
at io.realm.Realm.getInstance(Realm.java:197)
at de.myCompany.myApp.ImageDownloadController.fillDownloadStack(ImageDownloadController.java:94)
at de.myCompany.myApp.ImageDownloadController.<init>(ImageDownloadController.java:37)
at de.myCompany.myApp.ImageDownloadController.getInstance(ImageDownloadController.java:42)
at de.myCompany.myApp.helper.WifiReceiver.onReceive(WifiReceiver.java:30)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:862)
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:898)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
Is there any proper way to debug a RealmMigrationNeededException except for trial and error?
If a RealmMigrationExceptionNeeded error happens, Realm automatically tries to trigger any configured migration to fix it. If no such RealmMigration exists, you instead get another RealmMigrationNeededException that overrides the underlying cause.
The fix is to just provide a dummy RealmMigration to see the real error.
I can see why it can be a bit confusing, and we should probably consider throwing a better exception message that also include the underlying cause.
So I'm on Mac osx, downloaded Android studio, downloaded intel HAXM, started scripting and got to the end of this tutorial:
https://developer.android.com/training/basics/firstapp/building-ui.html
The script actually runs, but when I go to run it through my emulator the emulator says "My First App has stopped working" and I get the below in the debug menu.
I followed the instructions carefully and have a basic understanding of Java so but am not familiar with Android whatsoever. Could anyone let me know where I'm going wrong?
Thanks in advance!
Cab_Russell
02-24 22:41:24.798 2781-2781/com.example.dannyrussell.myfirstapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.dannyrussell.myfirstapp, PID: 2781
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dannyrussell.myfirstapp/com.example.dannyrussell.myfirstapp.MyActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class button
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 #15: Error inflating class button
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
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.setContentView(ActionBarActivityDelegateBase.java:228)
at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
at com.example.dannyrussell.myfirstapp.MyActivity.onCreate(MyActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5933)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
The problem is identified in the stack trace (although perhaps obscurely).
When creating the view, Android creates Java objects for objects in the layout XML. It is saying it can't create a Java object for class "button". Since the class you probably want is "Button", make sure your layout XML is correct (it is case sensitive)
I have a project which uses two modules(libraries), I created some activity and its respective layout file in one of my library, I can't seem to add new views in that layout (Textview, Imageview etc). Here is the logcat output.
java.lang.NoSuchFieldError: No static field tv of type I in class Lcom/camera/sushant/opencamera/R$id; or its superclasses (declaration of 'com.camera.sushant.opencamera.R$id' appears in /data/app/com.streetspotr.streetspotr.staging-1/base.apk)
at com.camera.opencamera.MediaPreview.onCreate(MediaPreview.java:89)
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)
Apparently what was happening, I had layout with same name in my app module and my library module. So when packaging the application it was always taking the layout from my app module not library module. So I had to delete the layout in my app module and everything worked fine.
Moving a resource from your project to a library can lead to this problem as well. If you did this, cleaning the project solves the problem...