Unable to run Ionic app after updating Capacitor from v2 to v3 - getting a :app:processDebugMainManifest error

After updating my app to use Capacitor 3, I’m running into a problem with the new run command. It’s failing at the end, so I’m not able to debug my app on an android device at all until I resolve this.

Here is the main error message I get after running ionic cap sync and subsequently ionic cap run, then selecting “android”:

[capacitor]
[capacitor]         FAILURE: Build failed with an exception.
[capacitor]
[capacitor]         * What went wrong:
[capacitor]         Execution failed for task ':app:processDebugMainManifest'.
[capacitor]         > Task :capacitor-app:generateDebugRFile
[capacitor]         > Task :app:processDebugMainManifest FAILED
[capacitor]         > Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @22738b3d
[capacitor]

(full error message below)

I’ve looked online to see what this error means, but there doesn’t seem to be a clear answer. As far as I can tell, this problem seems to arise in processing the app’s Android Manifest file (which I’ve posted below also), but most of the questions mention that it could be something related to the minSdkVersion, or a duplicate element, or that it’s some problem with cordova on an old ionic version. I tried some applicable potential solutions, but none seemed to work.

I had also tried to create a fresh Ionic app to see if the problem localized to my app, but it seems like it isn’t, as I get the same error on the blank app. So it makes sense that this isn’t a problem with my app, but rather with something related to the build tools, maybe a version issue with Gradle, etc.

However, compiling my app in Android Studio works, so I don’t think it is a Gradle problem either, though I assume it could possibly be something else that capacitor depends on. Here’s my system/version info, for reference:

Software Version
OS Windows 10.0.19042
nodeJS v13.8.0
Java jdk v16.0.1 2021-04-20
Gradle v7.0
Ionic v6.16.3
@capacitor/cli v3.0.1
@capacitor/android v3.0.1
@capacitor/core v3.0.1
Vue v3

Here’s a Github repo of the fresh app I used, if anyone wants to take a look. It’s just a blank vue tabs app. The full console output and Android Manifest file are posted there, as they exceed this post’s character limit.

I can’t seem to figure out where the problem is, so if anyone has any suggestions, that’d be much appreciated. Maybe if anyone is able to run ionic cap run on a blank Vue app successfully, you could share what version of Java/Ionic/Gradle, etc. you are using, so I can also install the same versions?

As I suspected, the issue was caused by a version issue, specifically, with Java. Apparently, the JDK version should be v15, not v16, as I had it. After downgrading it to v15, the errors have disappeared.

Here are the steps I followed (for Windows):

  1. Download the correct version of openJDK from here.

  2. Unzip the file, and transfer the jdk-15 folder to C:\Program Files\Java\jdk-15 (I don’t think the location is really that important, as long as it won’t be moved/deleted accidentally).

  3. Open command prompt in administrator mode and set the JAVA_HOME environment variable to wherever you moved the jdk-15 folder to:

    setx JAVA_HOME "C:\Program Files\Java\jdk-15" /M
    
  4. Restart your computer.

  5. Delete the android folder (del android) and try running:

    ionic cap run
    

    …or, for live reloading:

    ionic cap run --livereload --external
    
  6. You may also need to set the environment variables ANDROID_SDK_ROOT and/or ANDROID_SDK_HOME variables also, if you get an error message about them.

    ANDROID_SDK_HOME - probably will be at C:\Android:

    setx ANDROID_SDK_HOME "C:\Android"
    

    ANDROID_SDK_ROOT - find the path in Android Studio by going to Tools > SDK Manager

    64d862e3a16a86168f74d3689415c4dd

    Then set that path to ANDROID_SDK_ROOT:

    setx ANDROID_SDK_ROOT "C:\Users\Me\AppData\Local\Android\Sdk" /M
    

    …and repeat steps 4 and 5.

2 Likes

Error: Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jdk-16.0.1

I don’t have jdk-16.0.1 again on my machine

@AbdulAzeez - Where is this error showing up? Did you install jdk-15 and change JAVA_HOME accordingly?

Yes i did…

Strange…what does your JAVA_HOME environment variable look like? Go to Start and search for Environment Variables, and open the first result. JAVA_HOME should be under System Variables. Is the path there correct? If not, change it to the correct one and restart the computer. If it is, maybe double check if it is actually valid.

Also this may or may not help, but if you close the terminal where you’re running the build from, and reopen it, does that do anything?

image

It says 15.0.2, maybe let me restart

It worked with jdk-15, not 15.0.2, for me, so that could be the issue also. Did restarting it solve the problem?

The Link to download jdk 15 you posted does not work, where can i get 15

It works now, let me download it

Now working, Thanks alot

After alot of restarts

That’s good, glad to hear it.