1

I have imported a project that was developed on Eclipse into Android Studio. The project is working perfectly when running\debugging it from Eclipse on my device.

When debugging from the Android Studio on my device, the application is crashing and no exception is being caught on the Android Studio.

When I place breakpoints, they work fine, so I know i'm debugging the correct code :)

Edit:

I have run it again and got the following Exception in the logcat (shouldn't the debugger stop somewhere in the code to show the Exception? like in the line that tries to access the file?):

2018-10-24 11:25:26.027 25903-25903/? E/libpersona: Couldn't open the File - /data/system/users/0/personalist.xml - No such file or directory
2018-10-24 11:25:31.735 23290-23301/? E/DatabaseUtils: Writing exception to parcel
    java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=25858, uid=10314 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
        at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:639)
        at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:505)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:217)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:102)
        at android.os.Binder.execTransact(Binder.java:682)

Although I do have permissions set in the AndroidMenifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.eibimalul.smartgallery"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_SOCIAL_STREAM"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Edit 2: The Solution:

So apparently I was missing 2 things:

  1. run-time permissions which I understood using this link here and with the help of @Pier Giorgio Misley's comment
  2. I was missing permissions on the AndroidManifest.xml:

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    
Eibi
  • 402
  • 4
  • 17
  • So in logcat aren you getting nothing? – Piyush Oct 24 '18 at 08:00
  • what have you selected in the "logcat" bottom tab, in the drop-down menu in the upper right corner? "show only selected application"? be sure you didn't write anything as a filter in the filter input box – Pier Giorgio Misley Oct 24 '18 at 08:08
  • I have selected my device, my application and errors only. I see an error saying: "can't open file - /data/system/users/0/personalist.xml - No such file or directory". This is not my file. – Eibi Oct 24 '18 at 08:12
  • Check that _No Filter_ should be selected and your app package name and device should be selected in logcat. – Piyush Oct 24 '18 at 08:18
  • @Piyush I have checked, it is set as you have described. – Eibi Oct 24 '18 at 08:31
  • 2
    you have to ask for permissions at runtime, adding them in manifest is no longer enough – Pier Giorgio Misley Oct 24 '18 at 08:37
  • 1
    If you want to break on exceptions in Android Studio: https://stackoverflow.com/questions/24718958/android-studio-ide-break-on-exception – nasch Oct 29 '18 at 06:58

1 Answers1

1

The solution:

Apparently I was missing 2 things:

  1. Run-time permissions which I understood using this link here and with the help of @Pier Giorgio Misley's comment
  2. I was missing permissions on the AndroidManifest.xml:

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    

I am not sure if that's the right way to do it (answering my own question that is), since I got help from few developers here (@Pier Giorgio Misley in particular) in the comments only, but I thought it is important to mark the question as answered.

Eibi
  • 402
  • 4
  • 17