Android Question display image give me error

MohammadNew

Active Member
Licensed User
Longtime User
Hello guys, I have problime in my app but before I used it many times without any problimes ,,
I do not know what happened.

I used "Debug" and "Release"

Debug > stop working

Release > give me messame "unfortunately [app. Name] has stopped"

this my code

B4X:
Sub chooser_Result(Success As Boolean, Dir As String, FileName As String) 
If Success Then                               
        Dim OutputStream1 As OutputStream
       OutputStream1.InitializeToBytesArray(1000)
         
            '''''''''''''''''''''''''''''
            Dim b As Bitmap                     
              b = LoadBitmap(Dir,FileName)
              b = CreateScaledBitmap(b, 200, 200, True)                
     
            b.WriteToStream(OutputStream1, 1000, "PNG")
     
            '''''''''''''''''''''''''''''
        buffer = OutputStream1.ToBytesArray   
          OutputStream1.Close

      ImageView1.Bitmap=LoadBitmap(Dir,FileName)

    Else
       ToastMessageShow("No image selected", True)
    End If
End Sub


Sub CreateScaledBitmap(Original As Bitmap, Width As Int, Height As Int, Filter As Boolean) As Bitmap
  Dim jo As JavaObject
  jo.InitializeStatic("android.graphics.Bitmap")
  Return jo.RunMethod("createScaledBitmap", Array (Original, Width, Height, Filter))
End Sub


Sub btnaddimgfromphone_Click
     If Chooser.IsInitialized = False Then
           Chooser.Initialize("chooser")
       End If
       Chooser.Show("image/*", "Choose image")
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Run your app in debug mode. You should see the logs in the logs tab:

SS-2016-06-20_08.50.29.png
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
Thanks Erel , Now when I run my app in debug mode is ok working good. but release does not work

B4X:
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
** Activity (main) Pause, UserClosed = true **
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Installing file.
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (service1) Create **
** Service (service1) Start **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
** Activity (main) Pause, UserClosed = true **
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Installing file.
PackageAdded: package:b4a.example
Copying updated assets files (2)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Raising.. mysql_status
Connected to Database
** Activity (main) Resume **
MySQL_Status(true,false,0)
MySQL_ListTables
Table: tpl1
Table: tpl2
btnFillListView()
MySQL_QueryResult({ColumnCount=3, RecordCount=2, TaskID=filllistview, ms=244})
ResultSet: {a1=1, a2=Mohammad, a3=Jeddah}
ResultSet: {a1=2, a2=Fahad, a3=Doha}
lvItemClick(0,{a1=1, a2=Mohammad, a3=Jeddah})
** Activity (main) Pause, UserClosed = false **
** Activity (addimg) Create, isFirst = true **
Raising.. mysql_status
Connected to Database
** Activity (addimg) Resume **
MySQL_Status(true,false,0)
MySQL_QueryResult({ColumnCount=4, RecordCount=0, TaskID=filllistview, ms=472})
MySQL_QueryResult({ColumnCount=1, RecordCount=1, TaskID=getmax, ms=473})
ResultSet: {max(id)=0}
** Activity (addimg) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
** Activity (addimg) Resume **
** Activity (addimg) Pause, UserClosed = false **
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
You can switch to USB debug mode instead of B4A-Bridge. It will allow you to read the logs in release mode as well.

How are you connecting to the MySQL database?

Thanks Erel,

is the same logs when I use bridge or USB debug mode . about mysql database is good no problem.
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
One of the causes for crashes in release mode is the NetworkOnMainThread test, which is disabled in debug mode. This is why I asked about the MySQL connection.

I'm sure that your library is asynchronous and is not the cause for this issue.

I think that because I have same app but I use sqlite database is working good. and I sent my app to DonMan to check what happened .
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
please Erel help me,

when I run my app with debug mode is ok work fine ,,,, but release does not work give me error !

do you have another code to select image and display on imageview ?

maybe fix the problem.
 
Upvote 0

MohammadNew

Active Member
Licensed User
Longtime User
You need to connect in USB debug mode and find the crash in the logs.

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Raising.. mysql_status
Connected to Database
** Activity (main) Resume **
** Activity (addimg) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
addimg_chooser_result (java line: 431)
java.lang.SecurityException: Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/919 from pid=10026, uid=10274 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
    at android.os.Parcel.readException(Parcel.java:1540)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
    at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:148)
    at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:689)
    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1131)
    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:970)
    at android.content.ContentResolver.openInputStream(ContentResolver.java:695)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:206)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:498)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at b4a.example.addimg._chooser_result(addimg.java:431)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.phone.Phone$ContentChooser$1.ResultArrived(Phone.java:843)
    at anywheresoftware.b4a.BA$4.run(BA.java:513)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:398)
    at b4a.example.addimg$ResumeMessage.run(addimg.java:296)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6220)
    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:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 
Upvote 0
Top