After ionic v6 update, apk build breaks

Hi everyone,

I have updated my Ionic app to the current version v6. After the update, my buildpipeline is working, but the resulting apk is not installable. It simply does not react on any phone. native-run also seems broken, it does not provide a device list. Installing the App with adb / debugging in Android works fine.

Please find below additional info, let me know if you need anything else

Thanks in advance and kind regards

Ionic info:

Ionic:

   Ionic CLI       : 6.18.1 (/home/user/.nvm/versions/node/v14.16.1/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 6.0.2

Capacitor:

   Capacitor CLI      : 3.3.4
   @capacitor/android : 3.3.4
   @capacitor/core    : 3.3.4
   @capacitor/ios     : 3.3.4

Utility:

   cordova-res (update available: 0.15.4) : 0.15.3
   native-run                             : 1.5.0

System:

   NodeJS : v14.16.1 (/home/user/.nvm/versions/node/v14.16.1/bin/node)
   npm    : 6.14.12
   OS     : Linux 5.13

capacitor.config.json:

{
	"appId": "de.app",
	"appName": "app",
	"bundledWebRuntime": false,
	"npmClient": "npm",
	"webDir": "build",
	"plugins": {
		"SplashScreen": {
			"launchAutoHide": false,
			"splashFullScreen": true,
			"splashImmersive": true
		}
	},
	"cordova": {},
	"server": {
		"cleartext": true
	}
}

ionic.config.json:

{
  "name": "app",
  "proxies": [
    {
      "path": "/localhost",
      "proxyUrl": "http://localhost:8100"
    }
  ],
  "integrations": {
    "capacitor": {}
  },
  "type": "react"
}

build commands:

npm run build:demo
ionic cap add android
ionic cap add ios
cordova-res --skip-config --copy
npx jetify
ionic cap sync
./gradlew assembleDebug

package.json:

{
  "name": "app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@awesome-cordova-plugins/call-number": "^5.37.3",
    "@awesome-cordova-plugins/core": "^5.37.3",
    "@awesome-cordova-plugins/email-composer": "^5.37.3",
    "@awesome-cordova-plugins/file": "^5.37.3",
    "@awesome-cordova-plugins/file-opener": "^5.37.3",
    "@awesome-cordova-plugins/local-notifications": "^5.37.3",
    "@capacitor/android": "3.3.4",
    "@capacitor/app": "^1.0.7",
    "@capacitor/core": "3.3.4",
    "@capacitor/device": "^1.1.1",
    "@capacitor/haptics": "1.1.3",
    "@capacitor/ios": "^3.3.4",
    "@capacitor/keyboard": "1.2.0",
    "@capacitor/splash-screen": "^1.2.0",
    "@capacitor/status-bar": "1.0.6",
    "@capacitor/storage": "^1.2.3",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/fingerprint-aio": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic/react": "^6.0.2",
    "@ionic/react-router": "^6.0.2",
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "@types/jest": "^27.4.0",
    "@types/node": "^17.0.8",
    "@types/react": "^17.0.38",
    "@types/react-dom": "^17.0.11",
    "@types/react-router": "^5.1.11",
    "@types/react-router-dom": "^5.1.7",
    "call-number": "^1.0.1",
    "capacitor-secure-storage-plugin": "^0.6.2",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-email-composer": "^0.10.0",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-opener2": "^3.0.5",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "date-fns": "^2.28.0",
    "env-cmd": "^10.1.0",
    "ionicons": "^6.0.0",
    "jetifier": "^2.0.0",
    "native-run": "^1.5.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "5.0.0",
    "rxjs": "^7.5.1",
    "swiper": "^6.8.4",
    "typescript": "^4.1.3",
    "web-vitals": "^2.1.3",
    "workbox-background-sync": "^6.4.2",
    "workbox-broadcast-update": "^6.4.2",
    "workbox-cacheable-response": "^6.4.2",
    "workbox-core": "^6.4.2",
    "workbox-expiration": "^6.4.2",
    "workbox-google-analytics": "^6.4.2",
    "workbox-navigation-preload": "^6.4.2",
    "workbox-precaching": "^6.4.2",
    "workbox-range-requests": "^6.4.2",
    "workbox-routing": "^6.4.2",
    "workbox-strategies": "^6.4.2",
    "workbox-streams": "^6.4.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "build:demo": "env-cmd -f .env.demo ionic build --prod",
    "test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!(@ionic/react|@ionic/react-router|@ionic/core|@stencil/core|ionicons)/)'",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@capacitor/cli": "3.3.4"
  },
  "description": "An Ionic project"
}

Follow-up: I debugged the installation and I get the error

Requesting uid 10082 needs to declare permission android.permission.REQUEST_INSTALL_PACKAGES

I tried to add the permission to the manifest that was generated from Ionic but it doesn’t seem to be considered. Any help is appcreciated.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.mindu">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name="de.app.MainActivity"
            android:label="@string/title_activity_main"
            android:theme="@style/AppTheme.NoActionBarLaunch"
            android:launchMode="singleTask">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"></meta-data>
        </provider>
    </application>

    <!-- Permissions -->

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>

Thanks and kind regards

Hello everyone,

the issue is, that the permissions are after the application tag. The manifest file is therefore generated incorrectly by ionic. If someone experiences this issue, simply move the permissions above the application tag.

Have a good one

After tinkering about, this does not seem like a proper solution. I can’t seem to figure out where this needs to be placed…

After a factory reset on the testers phone, the app can be installed again. Closing this topic.