Urgent - INSTALL_FAILED_INVALID_APK with Android 14

Hello,

I encounter an issue that I don’t understand exactly what is wrong.
In fact, the build is ok and validated by Apple and Android.

It works fine on IOS and Android excepted for the version 14.

When I try to open my app on an Android device with Android 14, The app opens and close directly.
I can see an error message with this INSTALL_FAILED_INVALID_APK.

What should I have to do to fix this?

Many thanks for your help,
Loïc

Have you tried just creating a new build and uploading to Google Play?

Hello,

Yes, I tried to build the app again but when I open a simulator with Android 14. It doesn’t work unlike with Android 13 :confused:

Is there a way to check if the app code is compatible with Android 14 requierments?

I can see these errors in the logcat of the simulator:

2024-07-19 18:59:34.342 15711-15711 TransactionExecutor     com.app.my                    E  Failed to execute the transaction: tId:-1500070982 
ClientTransaction {
    tId:-1500070982   transactionItems = [
    tId:-1500070982     LaunchActivityItem{activityToken=android.os.BinderProxy@ddfb1e3,intent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.app.my/.MainActivity },ident=21483193,info=ActivityInfo{6789bed com.app.my.MainActivity},curConfig={1.0 310mcc260mnc [en_US] ldltr sw448dp w448dp h928dp 480dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1344, 2992) mAppBounds=Rect(0, 136 - 1344, 2920) mMaxBounds=Rect(0, 0 - 1344, 2992) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.3 s.117 fontWeightAdjustment=0},overrideConfig={1.0 310mcc260mnc [en_US] ldltr sw448dp w448dp h928dp 480dpi nrml long port finger qwerty/v/v dpad/v winConfig={ mBounds=Rect(0, 0 - 1344, 2992) mAppBounds=Rect(0, 136 - 1344, 2920) mMaxBounds=Rect(0, 0 - 1344, 2992) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.3 s.3 fontWeightAdjustment=0},deviceId=0,referrer=com.android.shell,procState=2,state=null,persistentState=null,pendingResults=null,pendingNewIntents=null,sceneTransitionInfo=null,profilerInfo=null,assistToken=android.os.BinderProxy@6179a96,shareableActivityToken=android.os.BinderProxy@f2ab617,activityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 1344, 2992), taskFragmentBounds=Rect(0, 0 - 1344, 2992)}}
    tId:-1500070982     ResumeActivityItem{mActivityToken=android.os.BinderProxy@ddfb1e3,procState=-1,updateProcState=false,isForward=true,shouldSendCompatFakeFocus=false}
    tId:-1500070982     Target activity: com.app.my.MainActivity
    tId:-1500070982   ]
    tId:-1500070982
}


---------------------------

2024-07-19 18:59:34.344 15711-15711 AndroidRuntime          com.app.my                    E  FATAL EXCEPTION: main
    Process: com.app.my, PID: 15711
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.my/com.app.my.MainActivity}: java.lang.SecurityException: com.app.my: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4047)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4234)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:112)
        at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
        at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2635)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loopOnce(Looper.java:232)
        at android.os.Looper.loop(Looper.java:317)
        at android.app.ActivityThread.main(ActivityThread.java:8699)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
    Caused by: java.lang.SecurityException: com.app.my: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
        at android.os.Parcel.createExceptionOrNull(Parcel.java:3242)
        at android.os.Parcel.createException(Parcel.java:3226)
        at android.os.Parcel.readException(Parcel.java:3209)
        at android.os.Parcel.readException(Parcel.java:3151)
        at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6066)
        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1880)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1820)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1808)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:757)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:757)
        at com.capacitorjs.plugins.share.SharePlugin.load(SharePlugin.java:44)
        at com.getcapacitor.PluginHandle.loadInstance(PluginHandle.java:115)
        at com.getcapacitor.PluginHandle.load(PluginHandle.java:105)
        at com.getcapacitor.PluginHandle.<init>(PluginHandle.java:65)
        at com.getcapacitor.Bridge.registerPlugin(Bridge.java:638)
        at com.getcapacitor.Bridge.registerAllPlugins(Bridge.java:594)
        at com.getcapacitor.Bridge.<init>(Bridge.java:213)
        at com.getcapacitor.Bridge.<init>(Unknown Source:0)
        at com.getcapacitor.Bridge$Builder.create(Bridge.java:1513)
        at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:42)
        at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:36)
        at android.app.Activity.performCreate(Activity.java:8980)
        at android.app.Activity.performCreate(Activity.java:8958)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1526)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4029)
        ... 13 more
    Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.am.ActivityManagerService.registerReceiverWithFeatureTraced(ActivityManagerService.java:14850)
        at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:14652)
        at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2743)
        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2818)
        at android.os.Binder.execTransactInternal(Binder.java:1500)

Does this mean something to you @twestrick?

Or maybe someone else?

No idea, but found this SO - android - One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts - Stack Overflow

Assuming you are running Capacitor 6?

Can you share the results from ionic info and your package.json? I am going to guess it is a Capacitor plugin that hasn’t been updated to support what the SO post is talking about.

Hello,

Thank you for your reply :slight_smile:

No, for this build, I’m using Capacitor v5. I will upgrade for the next version seen.

Here is the info info return:

Ionic:

   Ionic CLI                     : 7.2.0 (.../versions/node/v18.19.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 7.6.4
   @angular-devkit/build-angular : 16.0.5
   @angular-devkit/schematics    : 16.1.5
   @angular/cli                  : 16.0.4
   @ionic/angular-toolkit        : 10.0.0

Capacitor:

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

Cordova:

   Cordova CLI       : not installed
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res                          : not installed globally
   native-run (update available: 2.0.1) : 1.7.2

System:

   Android SDK Tools : 26.1.1 (.../Android/sdk)
   NodeJS            : v18.19.0 (.../versions/node/v18.19.0/bin/node)
   npm               : 10.2.3
   OS                : macOS Unknown
   Xcode             : Xcode 15.4 Build version 15F31d

And here is what I have in the package.json file:

{
  "name": "myApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^16.0.4",
    "@angular/cli": "^16.0.4",
    "@angular/common": "^16.0.4",
    "@angular/core": "^16.0.4",
    "@angular/forms": "^16.0.4",
    "@angular/localize": "^16.0.4",
    "@angular/platform-browser": "^16.0.4",
    "@angular/platform-browser-dynamic": "^16.0.4",
    "@angular/router": "^16.0.4",
    "@auth0/angular-jwt": "^5.1.2",
    "@awesome-cordova-plugins/core": "^6.4.0",
    "@awesome-cordova-plugins/device-orientation": "^6.4.0",
    "@babel/traverse": "^7.24.1",
    "@capacitor-community/barcode-scanner": "^4.0.1",
    "@capacitor-community/file-opener": "^1.0.5",
    "@capacitor-community/firebase-analytics": "^5.0.1",
    "@capacitor/android": "5.2.2",
    "@capacitor/app": "^5.0.6",
    "@capacitor/app-launcher": "^5.0.6",
    "@capacitor/camera": "^5.0.7",
    "@capacitor/clipboard": "^5.0.6",
    "@capacitor/core": "^5.2.2",
    "@capacitor/device": "^5.0.6",
    "@capacitor/filesystem": "5.1",
    "@capacitor/haptics": "^5.0.6",
    "@capacitor/ios": "^5.2.2",
    "@capacitor/keyboard": "^5.0.8",
    "@capacitor/network": "^5.0.6",
    "@capacitor/share": "^5.0.6",
    "@capacitor/splash-screen": "^5.0.6",
    "@capacitor/status-bar": "^5.0.6",
    "@ionic/angular": "^7.6.4",
    "@ionic/storage-angular": "^4.0.0",
    "@ngrx/effects": "^16.0.1",
    "@ngrx/store": "^16.0.1",
    "@ngrx/store-devtools": "^16.0.1",
    "@ngx-translate/core": "^15.0.0",
    "@ngx-translate/http-loader": "^8.0.0",
    "@transistorsoft/capacitor-background-fetch": "^5.2.5",
    "@transistorsoft/capacitor-background-geolocation": "^5.4.2",
    "angular-draggable-droppable": "^8.0.0",
    "canvas-confetti": "^1.9.3",
    "capacitor-native-settings": "^5.0.0",
    "cordova-plugin-device-orientation": "^2.0.1",
    "cordova-plugin-ios-disableshaketoedit": "^1.0.0",
    "core-js": "^3.31.1",
    "date-fns": "^2.30.0",
    "es6-promise-plugin": "^4.2.2",
    "geolib": "^3.3.4",
    "gsap": "^3.11.5",
    "jquery": "^3.6.4",
    "js-marker-clusterer": "^1.0.0",
    "lodash": "^4.17.21",
    "lodash-es": "^4.17.21",
    "mapbox-gl": "^3.3.0",
    "ngx-image-cropper": "^7.0.2",
    "rxjs": "^7.5.0",
    "swiper": "^7.4.1",
    "tslib": "^2.6.1",
    "zone.js": "^0.13.1"
  },
  "devDependencies": {
    "@angular-devkit/architect": "^0.1600.4",
    "@angular-devkit/build-angular": "^16.0.4",
    "@angular-devkit/core": "16.1.5",
    "@angular-devkit/schematics": "16.1.5",
    "@angular-eslint/builder": "16.3.1",
    "@angular-eslint/eslint-plugin": "16.3.1",
    "@angular-eslint/eslint-plugin-template": "16.3.1",
    "@angular-eslint/schematics": "16.3.1",
    "@angular-eslint/template-parser": "16.3.1",
    "@angular/compiler": "^16.0.4",
    "@angular/compiler-cli": "^16.0.4",
    "@angular/language-service": "^16.0.4",
    "@capacitor/cli": "^5.2.2",
    "@ionic/angular-toolkit": "^10.0.0",
    "@ionic/lab": "^3.2.15",
    "@types/jasmine": "^4.3.5",
    "@types/jasminewd2": "^2.0.10",
    "@types/jquery": "^3.5.16",
    "@types/node": "^18.16.2",
    "@typescript-eslint/eslint-plugin": "5.62.0",
    "@typescript-eslint/parser": "5.62.0",
    "eslint": "^8.51.0",
    "jasmine-core": "^5.1.0",
    "jasmine-spec-reporter": "^7.0.0",
    "karma": "^6.4.2",
    "karma-chrome-launcher": "^3.2.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-html-reporter": "^2.1.0",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.5"
  },
  "description": "An Ionic project",
  "browserslist": [
    "Chrome >=60",
    "ChromeAndroid >=60",
    "Firefox >=63",
    "Firefox ESR",
    "Edge >=79",
    "Safari >=13",
    "iOS >=13"
  ]
}

Do you see something wrong?

Thanks again for your help!
Loïc

I looked through several of your plugins (not all of them) and found @capacitor/network is using a BroadcastReceiver.

It is not setting the required flag on line 144 (even in v6).

activity.registerReceiver(receiver, filter);

I am guessing this is the issue. I could be wrong :upside_down_face:

Interesting, looking at your logs again, the stack trace is within the @capacitor/share plugin. It is setting the flag on Line 49.

ContextCompat.registerReceiver(
    getContext(),
    broadcastReceiver,
    new IntentFilter(Intent.EXTRA_CHOSEN_COMPONENT),
    ContextCompat.RECEIVER_EXPORTED
);

EDIT
I am using the share plugin on Android 14 without issue with Capacitor 5 :thinking:

Hi again,

thank you very much for taking the time to help me with this :slight_smile:

Hmm ok, so what can I do to fix it? Is there a workaround that I can use?

EDIT: Yes, this is very strange :confused:

OH! v5 of the Share plugin doesn’t have it.

getActivity().registerReceiver(broadcastReceiver, new IntentFilter(Intent.EXTRA_CHOSEN_COMPONENT));

Sooo, upgrade to Capacitor 6? :grin: Still weird that it is working in my app. Otherwise, try setting the flag yourself in the source (obviously it would switch back if you do a cap sync or npm update).

I opened up my project in Android Studio and went to the Share plugin and replaced the load method with the code from v6. It is building. Can’t easily test on Android 14. My test device is Android 12.

@Override
public void load() {
    broadcastReceiver =
        new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                    chosenComponent = intent.getParcelableExtra(Intent.EXTRA_CHOSEN_COMPONENT, ComponentName.class);
                } else {
                    chosenComponent = getParcelableExtraLegacy(intent, Intent.EXTRA_CHOSEN_COMPONENT);
                }
            }
        };
    ContextCompat.registerReceiver(
        getContext(),
        broadcastReceiver,
        new IntentFilter(Intent.EXTRA_CHOSEN_COMPONENT),
        ContextCompat.RECEIVER_EXPORTED
    );
}

Ok, I will test this tomorrow.

I already start to migrate to v6 but I have to make some adaptations because some packages are not compatible. That’s why I preferred to send this version of my application with v5 before migrating :stuck_out_tongue:

Thanks again and good evening!

1 Like

Hello,

Do you know if it is possible to roll back the active version of the application in Google Play Store to go back to the previous one?

Some Googling says it’s not possible :frowning:

One other thought. Did you by chance change compileSdkVersion or targetSdkVersion in your variables.gradle file from 33 to 34 before upgrading to Capacitor 6?

Hello,

Some Googling says it’s not possible :frowning:

Yes, I did some googling too and found the same as you but I preferred to ask (if I had ever missed something) :slight_smile:

One other thought. Did you by chance change compileSdkVersion or targetSdkVersion in your variables.gradle file from 33 to 34 before upgrading to Capacitor 6?

Yes I did, because I did not able to submit the app to Google without changing this variables and I see messages that informs me that I have to upgrade to 34 to be accepted in the Google Play Console.

When I go back to 33, I can open the app with Android 14 (so great it was about it) but it seems that I can’t send the app to production anymore regarding the errors/warnings in Google Play Console.

Will send a new version with v6 soon.




To fix the issue, I re-send the previous version of the app with a new version number. I don’t know if it will be validated by Google… (I’m not always very comfortable with native API changes with Ionic).


I also upgrade the app to Ionic 8 and Capacitor 6.

Now, I can launch the app in Android 14 on simulator and read devices :slight_smile:

I just have to adapt some codes/packages and test all the app before (ex: use a v6 compatible qr-scanner) before pushing it in stores.

Thanks again for your help,
Loïc

Great! In most cases you don’t want to change the SDK versions in your variables.gradle file unless you are upgrading Capacitor to a version that supports those SDK versions. Otherwise there is a possibility of running into issues like this.

The Warning in the Google Play console about SDK versions is just that, a warning. Google shouldn’t reject your app until after August 31 :grin:

Yes, I told myself that I was going to update the variable since it will have to be done and that I was going to send a new version. I should have refrained from doing so.

But anyway… we found what was causing the problem.
Once I have completely migrated to Capacitor v6 this will no longer be a problem :stuck_out_tongue:

thanks again for your help.

Have a nice day,
Loïc

1 Like