BuildmLearn / BuildmLearn-Toolkit-Android

This repository contains the Android version of the BuildmLearn Toolkit. BuildmLearn Toolkit is an easy-to-use program that helps the users make mobile apps without any knowledge of application development.
BSD 3-Clause "New" or "Revised" License
57 stars 132 forks source link

App crashes while trying to create from template for the first time after installation. #348

Open archie94 opened 7 years ago

archie94 commented 7 years ago

After installation when we try to create an app from a template the app crashes after asking for read-write permissions and we are back at the TemplateActivity. It works fine from here so the crash is probably due to some storage anomalies. Found on CyanogenMod v13 (Android 6.0.1)

permission crash

opticod commented 7 years ago

@archie94, I tried repeating on my device Moto G3 API 6.0.1, its not crashing even not for the first time. It may be problem with some devices. You can make a pr for the fix.

opticod commented 7 years ago

@archie94 , Is there any process in this issue?

archie94 commented 7 years ago

@opticod Extremely sorry for such a late reply! Last few weeks have been busy for me.

Yes, this problem is definitely a regular in CM, not so in other devices running OxygenOS or any version of android. I was thinking of asking for permissions right after the tutorial instead of project creation. Yet to test this and will definitely make a pr after this weekend!

opticod commented 7 years ago

@archie94 Cool. U mean by adding it in template list ? Can you analyse a bit, why its showing error for CM devices but not for other devices ?

archie94 commented 7 years ago

@opticod The problem does not appear to be the place where the permission is asked. You see when permission in granted we are explicitly creating a new instance of Toolkit application.

At least in CM the new instance gives java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File android.content.Context.getFilesDir()' on a null object reference. The Application instance crashes then restarts and works fine after this. I have tried not creating a new instance of Application after receiving the permissions from user. However it seems doing that we are unable to write to external storage and all our project is being saved at the private directory of application.

So in CM, we are unable to create a new instance of Application as it crashes with the error. Using the same instance of Application does not seem to reflect the grant of permission until the app is restarted by the user. Give me a few days as to see why other devices are not behaving like this. Thanks!

opticod commented 7 years ago

@archie94 Cool, thats'why i asked for a depth analysis of the problem. Let us know once you are done.