Skip to content

React Native Android Native Module Works Well on Debug but Doesn’t Work on Release

I’ve created an Android Native Module in my React Native App to get User Installed Apps List. it works well on Debug but doesn’t work on Release.

*Note : I’ve also tried to use a npm package called react-native-android-installed-apps, but it doesn’t work, so I decided to created a Native Module.

I don’t know what’s wrong that caused my Native Module works on Debug but doesn’t work on Release. It will be great and I’ll really appriciate it if anyone can point out to me what’s wrong.

Here’s my code:

public void getUserInstalledApps(Callback successCallback) throws JSONException {
 PackageManager pm = reactContext.getPackageManager();
 WritableArray array = new WritableNativeArray();
 List<AppList> apps = new ArrayList<AppList>();
 Gson g = new Gson();
 List<PackageInfo> packs = reactContext.getPackageManager().getInstalledPackages(0);
 for (int i = 0; i < packs.size(); i++) {
   PackageInfo p = packs.get(i);
     if ((!isSystemPackage(p))) {
       String appName = p.applicationInfo.loadLabel(reactContext.getPackageManager()).toString();
       String packages = p.applicationInfo.packageName;
       apps.add(new AppList(appName, packages));

   for (AppList co : apps) {
     JSONObject jo = new JSONObject(g.toJson(co));
     WritableMap wm = convertJsonToMap(jo);


private boolean isSystemPackage(PackageInfo pkgInfo) {
  return (pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;

public class AppList {
 private String name;
 private String packages;

 public AppList(String name, String packages) { = name;
   this.packages = packages;

 public String getName() {
   return name;
 public String getPackages() {
   return packages;



I’ve fix it by adding some pro-guard rules for my Native Module