capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

[Android Studio] Errors after Capacitor update in Android Studio

Open peterpeterparker opened this issue 8 years ago • 46 comments

[X] I would to submit a bug or support question

Current behavior

I'm not sure if it's a bug or just something I should ignore, but each time I update capacitor in my existing test project, build, copy and then open Android Studio I face the following errors (first error popup straight after Android Studio open, the other one after automatic build)

16.03.18 15:02 Unsupported Modules Detected: Compilation is not supported for following modules: assets-capacitor-android-plugins~1, capacitor-android-plugins. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

15:02 Unsupported Modules Detected: Compilation is not supported for following modules: assets-capacitor-android-plugins~1, capacitor-android-plugins. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

15:02 Unregistered VCS root detected The directory /Users/me/Documents/projects/lab/capacitor-camera is under Git, but is not registered in the Settings. Add root Configure Ignore

15:03 Gradle sync started

15:03 Error Loading Project: Cannot load module assets-capacitor-android-plugins Details...

15:03 Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google Play services

15:03 Project setup started

15:03 Gradle sync failed: java.lang.NullPointerException (41s 709ms)

android_studio_error_after_update

Expected behavior

No error I guess, but like I said, maybe I do something wrong

Current way to solve this

To solve this, each time I remove the "platform"

rm -r android

and then add it again

npx cap add android
npx cap sync
npx cap open android

Steps to reproduce

npm remove --save @capacitor/core @capacitor/cli
npm install --save @capacitor/core @capacitor/cli
ionic build --prod
npx cap copy
npx cap open android

p.s.: all the above steps are successful and produce no errors

Others informations


Gradle 4.6

Groovy: 2.4.12 Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017 JVM: 1.8.0_60 (Oracle Corporation 25.60-b23) OS: Mac OS X 10.12.6 x86_64

peterpeterparker avatar Mar 16 '18 14:03 peterpeterparker

Do you have cordova plugins in your project?

jcesarmobile avatar Mar 16 '18 14:03 jcesarmobile

@jcesarmobile to create the project I did "ionic start ..." answered no to "would you like to add iOS/android" and then as described in the doc, as far as I remember, deleted the splash screen plugin

peterpeterparker avatar Mar 16 '18 14:03 peterpeterparker

@jcesarmobile to create the project I did "ionic start ..." answered no to "would you like to add iOS/android" and then as described in the doc, as far as I remember, deleted the splash screen plugin

but like I said, it's an existing one (the one I use for my camera tests)

peterpeterparker avatar Mar 16 '18 14:03 peterpeterparker

what template did you choose?

jcesarmobile avatar Mar 16 '18 14:03 jcesarmobile

@jcesarmobile menu ("hamburger menu top left")

peterpeterparker avatar Mar 16 '18 14:03 peterpeterparker

I'm not able to reproduce, but might be related to removing capacitor cli as we write a lot of things there, so after removing it, better run a cap sync or cap update to make sure everything is recreated, specially if you have Cordova or custom plugins.

jcesarmobile avatar Mar 16 '18 15:03 jcesarmobile

Same same.

You know what, this problem appears because Android Studio, the very first time I open the project (npx cap open android after having created a fresh new platform like described above) in it, create a folder capacitor-android-plugins with the following manifests/AndroidManifest.xml file in it

<?xml version='1.0' encoding='utf-8'?>
  <manifest package='capacitor.android.plugins' xmlns:android='http://schemas.android.com/apk/res/android'>
</manifest>

Then, if I close it and open it again, it will try to compile this and complains.

Does that make sense? Do you also have such a folder/file in your project?

android_studio_error_plugin_manifest

peterpeterparker avatar Mar 16 '18 16:03 peterpeterparker

Yeah, I have it and doesn't complain about it

jcesarmobile avatar Mar 16 '18 16:03 jcesarmobile

Weird....I'll keep an eye on it. I saw that I "need" to update one or two Android libs, maybe it will help

peterpeterparker avatar Mar 17 '18 08:03 peterpeterparker

Maybe it is because the android studio files are committed. I had the same issue. After removing them it was not a problem any longer. I modified the default gitignore to reflect this: https://github.com/ionic-team/capacitor/pull/378

JStumpp avatar Mar 26 '18 14:03 JStumpp

Keeping an eye on this. I haven't run into it myself

mlynch avatar Mar 26 '18 21:03 mlynch

cool @JStumpp I'll will keep an eye on it too

if I can't reproduce it anymore, count on me to close the issue

peterpeterparker avatar Mar 27 '18 04:03 peterpeterparker

mmmmh I could "still" reproduce the problem after upgrading from alpha25 to alpha31

I tried to remove the git origin (git remote rm origin) but they were none to remove

so I did

npm install --save @capacitor/core @capacitor/cli
ionic build --prod
npx cap sync
npx cap open android

peterpeterparker avatar Mar 27 '18 19:03 peterpeterparker

I've left the project for about a week, then when returned faced the same set of errors. I even didn't change anything in it!

npx cap sync or npx cap update didn't make any difference, nor attempts to clear or rebuild project.

ArmorDarks avatar Jul 26 '18 16:07 ArmorDarks

Removing and adding android directory again helped, though, none of the tracked by Git files changed, so I assume it is something to do with files listed in .gitignore...

ArmorDarks avatar Jul 27 '18 19:07 ArmorDarks

Seems to be unrelated to the android directory at all, since resetting it to defaults doesn't help. However, resetting @capacitor node_modules content does help.

I assume Gradle writes in Capacitor node_modules something that later leads to this issue.

ArmorDarks avatar Jul 30 '18 14:07 ArmorDarks

I had the same problem after I've returned to my project and updated the capacitor.

However, invalidating the cache and restarting (File > Invalidate Caches/Restart) did the job. Is that something you've tried?

durasj avatar Aug 29 '18 13:08 durasj

Closing without more info there's not much we can do here. Try invalidating caches and restarting as recommended above. It's just one of those things you get used to when doing Android development as Android Studio makes mistakes sometimes.

mlynch avatar Jan 24 '19 17:01 mlynch

I am still facing the issue

krithikuntukad avatar Nov 05 '19 08:11 krithikuntukad

same here

SergioSuarezGil avatar Nov 05 '19 14:11 SergioSuarezGil