title: How to make my Android APK compatible across multiple devices?
body: <p>For context, I'm trying to create an Android app in Java that can share itself to other phones. I managed to get the app to successfully send its own APK to another android phone using bluetooth (see implementation below).</p>
  <p>The problem is that the APK from one phone will not install on another phone. To troubleshoot, I downloaded a third-party APK extractor to send my app across with the same results - the APK is successfully transferred but won't install on the other phone. I then tried to use the APK extractor to share a random selection of Google Play apps, some apps would successfully install on the second phone, others wouldn't.</p>
  <p>At this stage, I'm quiet sure this is a compatibility issue. How could I make my APK be more compatible across devices? For reference, I'm currently testing it on 3 phones: Samsung Galaxy S7, Huawei Nova 3i and Motorolla XT1052, but ultimately I want the app to be accessible on as many devices as possible.</p>
  <p>Thanks in advance :)</p>
  <p><strong>sendApp Function</strong></p>
  <pre><code>public void sendApp(Activity activity) {
      try {
          PackageManager pm = activity.getPackageManager();
          ApplicationInfo app = pm.getApplicationInfo(activity.getPackageName(), 0);
          File apkFile = new File(app.publicSourceDir);
  
          Intent intent = new Intent(Intent.ACTION_SEND);
          intent.setType(&quot;*/*&quot;);
          Uri uri = FileProvider.getUriForFile(
                  getApplicationContext(),
                  BuildConfig.APPLICATION_ID + &quot;.provider&quot;, //(use your app signature + &quot;.provider&quot; )
                  apkFile);
          intent.putExtra(Intent.EXTRA_STREAM, uri);
          intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
          startActivity(intent);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  <p><strong>Manifest.xml Provider Tag:</strong></p>
  <pre><code>    &lt;provider
          android:name=&quot;androidx.core.content.FileProvider&quot;
          android:authorities=&quot;${applicationId}.provider&quot;
          android:exported=&quot;false&quot;
          android:grantUriPermissions=&quot;true&quot;&gt;
          &lt;!-- resource file to create --&gt;
          &lt;meta-data
              android:name=&quot;android.support.FILE_PROVIDER_PATHS&quot;
              android:resource=&quot;@xml/file_paths&quot;&gt;
          &lt;/meta-data&gt;
      &lt;/provider&gt;
  </code></pre>
  <p><strong>file_paths.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;paths&gt;
      &lt;root-path
          name=&quot;root&quot;
          path=&quot;.&quot;/&gt;
  &lt;/paths&gt;
  </code></pre>