It is causing me unable to inflate fragment. This is from the androidx library that cannot resolve symbol "R". I have tried clean, rebuild and even invalidate and restart. Also add in this specific dependency in gradle file and also deleted the gradle cache file to let it redownload when restart. It never get to fixed😢
Problem shown when at GragmentLayoutInflaterFactory.java
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.wayneyong.poibrowser, PID: 5527
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wayneyong.poibrowser/com.wayneyong.poibrowser.PoiBrowserActivity}: android.view.InflateException: Binary XML file line #121 in com.wayneyong.poibrowser:layout/activity_poi_browser: Binary XML file line #121 in com.wayneyong.poibrowser:layout/activity_poi_browser: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3308)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7560)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #121 in com.wayneyong.poibrowser:layout/activity_poi_browser: Binary XML file line #121 in com.wayneyong.poibrowser:layout/activity_poi_browser: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #121 in com.wayneyong.poibrowser:layout/activity_poi_browser: Error inflating class fragment
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference
at com.wayneyong.poibrowser.ar.ArFragmentSupport.createCameraView(ArFragmentSupport.java:139)
at com.wayneyong.poibrowser.ar.ArFragmentSupport.init(ArFragmentSupport.java:94)
at com.wayneyong.poibrowser.ar.ArFragmentSupport.onCreateView(ArFragmentSupport.java:182)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
at androidx.fragment.app.FragmentStateManager.ensureInflatedView(FragmentStateManager.java:386)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:281)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:140)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1073)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at com.wayneyong.poibrowser.databinding.ActivityPoiBrowserBinding.inflate(ActivityPoiBrowserBinding.java:113)
at com.wayneyong.poibrowser.databinding.ActivityPoiBrowserBinding.inflate(ActivityPoiBrowserBinding.java:107)
at com.wayneyong.poibrowser.PoiBrowserActivity.onCreate(PoiBrowserActivity.java:122)
at android.app.Activity.performCreate(Activity.java:7894)
at android.app.Activity.performCreate(Activity.java:7881)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7560)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I/Process: Sending signal. PID: 5527 SIG: 9
Related
Last time I opened the project, it was working but now the app keeps stopping. I didn't even change any code as far as I remember. I can't even open the app now
2022-06-07 21:06:18.942 7244-7244/com.example.labactivity01layoutsandactivity E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.labactivity01layoutsandactivity, PID: 7244
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.labactivity01layoutsandactivity/com.example.labactivity01layoutsandactivity.MainActivity}: java.lang.IllegalStateException: Activity com.example.labactivity01layoutsandactivity.MainActivity#661d5fe does not have a NavController set on 2131231012
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.IllegalStateException: Activity com.example.labactivity01layoutsandactivity.MainActivity#661d5fe does not have a NavController set on 2131231012
at androidx.navigation.Navigation.findNavController(Navigation.java:61)
at androidx.navigation.ActivityKt.findNavController(Activity.kt:30)
at com.example.labactivity01layoutsandactivity.MainActivity.onCreate(MainActivity.kt:26)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
All my files have no errors! But then also in LOGCAT after the app crashes an error pointing to my MainActivity.kt file is present. Once I click on it, it points to -> setContentView(R.layout.activity_main).
One more thing. When I click on the LOGCAT thing it says "sources for android api 32 not found" and above it, it says " decompile .class file, bytecode version 52.0(java 8) ".
Just to let you know that, I have only build my layout whereas I was going to build the MainActicity.kt file later.
I was assuming it is because of api or sdk mismatch or maybe some syntax in my xml which is not imported or something like that.
ERROR ->
2022-01-04 23:58:05.977 3507-3507/com.example.trail E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.trail, PID: 3507
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.trail/com.example.trail.MainActivity}: android.view.InflateException: Binary XML file line #49 in com.example.trail:layout/activity_main: Binary XML file line #49 in com.example.trail:layout/activity_main: Error inflating class Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: android.view.InflateException: Binary XML file line #49 in com.example.trail:layout/activity_main: Binary XML file line #49 in com.example.trail:layout/activity_main: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #49 in com.example.trail:layout/activity_main: Error inflating class Button
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 14 to dimension: type=0x10
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:787)
at android.view.View.<init>(View.java:5538)
at android.widget.TextView.<init>(TextView.java:996)
at android.widget.Button.<init>(Button.java:166)
at android.widget.Button.<init>(Button.java:141)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:80)
at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:224)
at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:220)
at com.google.android.material.theme.MaterialComponentsViewInflater.createButton(MaterialComponentsViewInflater.java:43)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:129)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1566)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1617)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1059)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:706)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at com.example.trail.MainActivity.onCreate(MainActivity.kt:9)
at android.app.Activity.performCreate(Activity.java:7994)
at android.app.Activity.performCreate(Activity.java:7978)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
2022-01-04 23:58:05.977 3507-3507/com.example.trail E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
BUTTON [ I was building a calculator and was trying for rounded buttons. When I did that it removed the boundaries too :(. I think I have imported something wrong maybe I am using some wrong import?]->
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#integer/margin"
android:padding="#integer/padding"
android:text="#string/divide"
android:textColor="#color/THEME1"
android:textSize="35sp"
app:cornerRadius="10dp" />
How it looks right now ->
android:layout_margin="#integer/margin"
android:padding="#integer/padding"
Use a dimen resource for margins and paddings. Raw number such as integer cannot be used as a dimension that also requires a unit such as dp.
I thought I should add a toolbar as I'll need a settings button.
So I added this to my main_activity.xml
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="PSA MFD"
app:subtitle="Multi functional display for Citroen and Peugeot"
app:logo="#android:drawable/ic_menu_call"
app:navigationIcon="#drawable/ic_fan"
/>
But now my app won't run because:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rwb.psamfd/com.rwb.psamfd.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/data/app/com.rwb.psamfd-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rwb.psamfd-2/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.rwb.psamfd.MainActivity.onCreate(MainActivity.kt:31)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
What do I ned to do? I have absolutely no idea. (I'm new to Android development -- and it's very difficult compared to C#).
Method 1:
Add the following to your dependencies in build.gradle file:
dependencies {
...
**implementation 'androidx.appcompat:appcompat:1.0.0'**
}
And change your toolbar as:
<androidx.appcompat.widget.Toolbar
....
Your contents
....>
<androidx.appcompat.widget.Toolbar/>
Method 2:
You can migrate to androidx directly.
Hope you will find the solution.
I cant get the directory , the IDE I am using is Android Studio using Kotlin language, I have inputted the exact path of the image directory which is "D:\Fyp\app\src\main\res\drawable\picture.jpg" , I have tried on IntelliJ with the same codes and it worked as well, but as for on android studio , it didnt work ... Below is the code ...
private fun encoder(): String {
val bytes = File("D:\\Fyp\\app\\src\\main\\res\\drawable\\picture.jpg").readBytes()
val base64 = Base64.getEncoder().encodeToString(bytes)
return base64
}
and these are the error logs ...
2019-12-16 20:26:24.415 15322-15322/com.example.fyp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.fyp, PID: 15322
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fyp/com.example.fyp.MainActivity}: java.io.FileNotFoundException: D:\Fyp\app\src\main\res\drawable\image.jpg: open failed: ENOENT (No such file or directory)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.io.FileNotFoundException: D:\Fyp\app\src\main\res\drawable\image.jpg: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:496)
at java.io.FileInputStream.<init>(FileInputStream.java:159)
at kotlin.io.FilesKt__FileReadWriteKt.readBytes(FileReadWrite.kt:63)
at com.example.fyp.MainActivity.encoder(MainActivity.kt:62)
at com.example.fyp.MainActivity.onCreate(MainActivity.kt:57)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)Â
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)Â
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)Â
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)Â
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)Â
at android.os.Handler.dispatchMessage(Handler.java:107)Â
at android.os.Looper.loop(Looper.java:214)Â
at android.app.ActivityThread.main(ActivityThread.java:7356)Â
at java.lang.reflect.Method.invoke(Native Method)Â
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)Â
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)Â
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:252)
at libcore.io.ForwardingOs.open(ForwardingOs.java:167)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7255)
at libcore.io.IoBridge.open(IoBridge.java:482)
at java.io.FileInputStream.<init>(FileInputStream.java:159)Â
at kotlin.io.FilesKt__FileReadWriteKt.readBytes(FileReadWrite.kt:63)Â
at com.example.fyp.MainActivity.encoder(MainActivity.kt:62)Â
at com.example.fyp.MainActivity.onCreate(MainActivity.kt:57)Â
at android.app.Activity.performCreate(Activity.java:7802)Â
at android.app.Activity.performCreate(Activity.java:7791)Â
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)Â
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)Â
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)Â
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)Â
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)Â
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)Â
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)Â
at android.os.Handler.dispatchMessage(Handler.java:107)Â
at android.os.Looper.loop(Looper.java:214)Â
at android.app.ActivityThread.main(ActivityThread.java:7356)Â
at java.lang.reflect.Method.invoke(Native Method)Â
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)Â
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)Â
It doesn't make sense to use the path of the file on your PC from your Android application.
Also, resources (anything in the res directory of your project) are not traditional files in your compiled application. You can't access them as files, and they might not even exist in the app after it is installed from the store (if they are filtered out based on device characteristics).
To include files in your app that you can load at run time, you need to put them in an assets directory, not in res. If you don't already have an assets directory, create one in src/main. Then put your files in it. You can read it like this:
val bytes = context.assets.open("picture.jpg").use { it.readBytes() }
Note the use of use wrapping the readBytes() call. This is to close the input stream after it's done reading. Otherwise, you leak the input stream.
01-07 14:19:21.816 9861-9861/? I/art: Late-enabling -Xcheck:jni
I am unable to rectify this error,
01-07 14:19:22.168 9861-9861/com.example.krishna.androideatit W/System: ClassLoader referenced unknown path: /data/app/com.example.krishna.androideatit-1/lib/arm64
01-07 14:19:22.202 9861-9861/com.example.krishna.androideatit I/art: Starting a blocking GC HeapTrim
01-07 14:19:22.211 9861-9861/com.example.krishna.androideatit I/InstantRun: starting instant run server: is main process
01-07 14:19:22.463 9861-9861/com.example.krishna.androideatit W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
01-07 14:19:22.615 9861-9861/com.example.krishna.androideatit D/skia: SkJpegCodec::onGetPixels +
01-07 14:19:22.620 9861-9861/com.example.krishna.androideatit D/skia: SkJpegCodec::onGetPixels -
01-07 14:19:22.665 9861-9872/com.example.krishna.androideatit I/art: Enter while loop.
01-07 14:19:22.741 9861-9861/com.example.krishna.androideatit D/AndroidRuntime: Shutting down VM
01-07 14:19:22.747 9861-9861/com.example.krishna.androideatit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.krishna.androideatit, PID: 9861
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.krishna.androideatit/com.example.krishna.androideatit.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.krishna.androideatit.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:6666)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6251)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:466)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance0(Native Method)Â
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)Â
at android.view.LayoutInflater.createView(LayoutInflater.java:645)Â
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)Â
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)Â
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)Â
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)Â
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)Â
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)Â
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)Â
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)Â
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)Â
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)Â
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)Â
at com.example.krishna.androideatit.MainActivity.onCreate(MainActivity.java:18)Â
at android.app.Activity.performCreate(Activity.java:6666)Â
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)Â
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)Â
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)Â
at android.app.ActivityThread.-wrap12(ActivityThread.java)Â
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)Â
at android.os.Handler.dispatchMessage(Handler.java:110)Â
at android.os.Looper.loop(Looper.java:203)Â
at android.app.ActivityThread.main(ActivityThread.java:6251)Â
at java.lang.reflect.Method.invoke(Native Method)Â
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)Â
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)Â
It is clearly written here that exception is due to
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.krishna.androideatit/com.example.krishna.androideatit.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
please provide your code fro more help