Add custom .aar library using AndroidX to Cordova pluginAndroid Studio: Add jar as library?Migrating to Gradle Plugin 3.0, aapt2 build errorGradle No class directories configured for FindBugs analysisGradle Error while building applicationAAPT2 error: this error happened as soon as i updated my android studio to the latest versionI am getting a java.nio.charset.MalformedInputException: Input length = 1 while gradle upgrade to version 3.1.4“Compilation failed; see the compiler error output for details.” errorImporting AndroidX (Jetpack) library into a non AndroidX AppAdd AAR file in ionic 3 application by creating custom pluginCordova Android error :app:transformClassesWithDesugarForDebug when adding plugin
Why do we read the Megillah by night and by day?
What is this called? Old film camera viewer?
What is Cash Advance APR?
Create all possible words using a set or letters
What does chmod -u do?
Can I sign legal documents with a smiley face?
Electoral considerations aside, what are potential benefits, for the US, of policy changes proposed by the tweet recognizing Golan annexation?
When a Cleric spontaneously casts a Cure Light Wounds spell, will a Pearl of Power recover the original spell or Cure Light Wounds?
Is the U.S. Code copyrighted by the Government?
GraphicsGrid with a Label for each Column and Row
Why did the EU agree to delay the Brexit deadline?
Redundant comparison & "if" before assignment
Is there a working SACD iso player for Ubuntu?
What prevents the use of a multi-segment ILS for non-straight approaches?
Why is it that I can sometimes guess the next note?
How can "mimic phobia" be cured or prevented?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
How should I respond when I lied about my education and the company finds out through background check?
Non-trope happy ending?
Did arcade monitors have same pixel aspect ratio as TV sets?
Should I outline or discovery write my stories?
Where did Heinlein say "Once you get to Earth orbit, you're halfway to anywhere in the Solar System"?
Problem with TransformedDistribution
What should you do if you miss a job interview (deliberately)?
Add custom .aar library using AndroidX to Cordova plugin
Android Studio: Add jar as library?Migrating to Gradle Plugin 3.0, aapt2 build errorGradle No class directories configured for FindBugs analysisGradle Error while building applicationAAPT2 error: this error happened as soon as i updated my android studio to the latest versionI am getting a java.nio.charset.MalformedInputException: Input length = 1 while gradle upgrade to version 3.1.4“Compilation failed; see the compiler error output for details.” errorImporting AndroidX (Jetpack) library into a non AndroidX AppAdd AAR file in ionic 3 application by creating custom pluginCordova Android error :app:transformClassesWithDesugarForDebug when adding plugin
Objective
I need to develop a plugin for Cordova that implements some code (aar file) I've already developed, for an android app.
System
- OS: Ubuntu 18.04.2 LTS
- IDEs: VSCode & Android Studio
- Phone: Nexus 4 - Android 5.1.1
- Cordova version: 8.1.2 (cordova-lib@8.1.1)
- SDK informations of the Cordova app(from build.gradle):
defaultBuildToolsVersion="27.0.1" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
What I've tried
- I've made a .aar file from that project & I'm trying to add it to my Cordova plugin. I can import the methods from that project, but the application crashes once I open the activity that uses those methods (the app still builds correctly).
03-21 12:35:59.728 12235-12235/io.cordova.hellocordova E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.cordova.hellocordova, PID: 12235
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
- I figured it might be because of
androidx
thanks toFailed resolution of: Landroidx/core/content/ContextCompat;
. So I added that line to myplugin.xml
file:
<!-- I have the same version of androidx.appcompat in my aar library -->
<framework src="androidx.appcompat:appcompat:1.0.0-beta01"/>
- With that change the app refuses to build and I get those errors (I replaced the absolute project path with
<projectpath>
):
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values-v28/values-v28.xml","position":"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/Documents/Projects/Git/CordovaPluginProcessSdk/MobileApp/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml","position":"startLine":10],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/fontVariationSettings not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/ttcIndex not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/fontVariationSettings not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
- With those errors, I've come to think that it might be an error between
cordova
andandroidx
library. To check that I've tried to add a different library (volley, which is not required for my aar library to work) with that line:
<framework src="com.android.volley:volley:1.1.1"/>
- The app builds successfully. But when I run it, it crashes once we start using elements from the AAR library. (cf. step 1)
Is Cordova compatible with androidx ? If it is, what is preventing me from using it ?
It looks like it's not compatible from the tests & errors I've got, but I haven't found relevant information on the subject on the Cordova documentation website or with a google search. So I can't confirm.
PS: I tried to be as exhaustive as possible, please ask if you're missing information.
Edit #1:
- I tried to change
androidx
back toappcompat
in my .aar library. I generated a new .aar & used
<framework src="com.android.support:appcompat-v7:28.0.0"/>
instead of the androidx import.
Result: Same as (1.) issue.
Conclusion: It might not be because of androidx
- I remembered that on the official doc of Cordova they're using an import of appcompat: Cordova - Plugin.xml - Framework. So I used this one:
<!-- Depend on v21 of appcompat-v7 support library -->
<framework src="com.android.support:appcompat-v7:21+" />
And it builds correctly. But still crashes because the function used in the .aar file doesn't exist for this version of the library.
Process: io.cordova.hellocordova, PID: 16523
java.lang.NoSuchMethodError: No static method checkSelfPermission(Landroid/content/Context;Ljava/lang/String;)I in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/io.cordova.hellocordova-2/base.apk)
If possible I would like to keep using androidx instead of appcompat because I have other modules that depend on it.
android cordova gradle plugins aar
add a comment |
Objective
I need to develop a plugin for Cordova that implements some code (aar file) I've already developed, for an android app.
System
- OS: Ubuntu 18.04.2 LTS
- IDEs: VSCode & Android Studio
- Phone: Nexus 4 - Android 5.1.1
- Cordova version: 8.1.2 (cordova-lib@8.1.1)
- SDK informations of the Cordova app(from build.gradle):
defaultBuildToolsVersion="27.0.1" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
What I've tried
- I've made a .aar file from that project & I'm trying to add it to my Cordova plugin. I can import the methods from that project, but the application crashes once I open the activity that uses those methods (the app still builds correctly).
03-21 12:35:59.728 12235-12235/io.cordova.hellocordova E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.cordova.hellocordova, PID: 12235
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
- I figured it might be because of
androidx
thanks toFailed resolution of: Landroidx/core/content/ContextCompat;
. So I added that line to myplugin.xml
file:
<!-- I have the same version of androidx.appcompat in my aar library -->
<framework src="androidx.appcompat:appcompat:1.0.0-beta01"/>
- With that change the app refuses to build and I get those errors (I replaced the absolute project path with
<projectpath>
):
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values-v28/values-v28.xml","position":"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/Documents/Projects/Git/CordovaPluginProcessSdk/MobileApp/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml","position":"startLine":10],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/fontVariationSettings not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/ttcIndex not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/fontVariationSettings not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
- With those errors, I've come to think that it might be an error between
cordova
andandroidx
library. To check that I've tried to add a different library (volley, which is not required for my aar library to work) with that line:
<framework src="com.android.volley:volley:1.1.1"/>
- The app builds successfully. But when I run it, it crashes once we start using elements from the AAR library. (cf. step 1)
Is Cordova compatible with androidx ? If it is, what is preventing me from using it ?
It looks like it's not compatible from the tests & errors I've got, but I haven't found relevant information on the subject on the Cordova documentation website or with a google search. So I can't confirm.
PS: I tried to be as exhaustive as possible, please ask if you're missing information.
Edit #1:
- I tried to change
androidx
back toappcompat
in my .aar library. I generated a new .aar & used
<framework src="com.android.support:appcompat-v7:28.0.0"/>
instead of the androidx import.
Result: Same as (1.) issue.
Conclusion: It might not be because of androidx
- I remembered that on the official doc of Cordova they're using an import of appcompat: Cordova - Plugin.xml - Framework. So I used this one:
<!-- Depend on v21 of appcompat-v7 support library -->
<framework src="com.android.support:appcompat-v7:21+" />
And it builds correctly. But still crashes because the function used in the .aar file doesn't exist for this version of the library.
Process: io.cordova.hellocordova, PID: 16523
java.lang.NoSuchMethodError: No static method checkSelfPermission(Landroid/content/Context;Ljava/lang/String;)I in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/io.cordova.hellocordova-2/base.apk)
If possible I would like to keep using androidx instead of appcompat because I have other modules that depend on it.
android cordova gradle plugins aar
add a comment |
Objective
I need to develop a plugin for Cordova that implements some code (aar file) I've already developed, for an android app.
System
- OS: Ubuntu 18.04.2 LTS
- IDEs: VSCode & Android Studio
- Phone: Nexus 4 - Android 5.1.1
- Cordova version: 8.1.2 (cordova-lib@8.1.1)
- SDK informations of the Cordova app(from build.gradle):
defaultBuildToolsVersion="27.0.1" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
What I've tried
- I've made a .aar file from that project & I'm trying to add it to my Cordova plugin. I can import the methods from that project, but the application crashes once I open the activity that uses those methods (the app still builds correctly).
03-21 12:35:59.728 12235-12235/io.cordova.hellocordova E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.cordova.hellocordova, PID: 12235
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
- I figured it might be because of
androidx
thanks toFailed resolution of: Landroidx/core/content/ContextCompat;
. So I added that line to myplugin.xml
file:
<!-- I have the same version of androidx.appcompat in my aar library -->
<framework src="androidx.appcompat:appcompat:1.0.0-beta01"/>
- With that change the app refuses to build and I get those errors (I replaced the absolute project path with
<projectpath>
):
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values-v28/values-v28.xml","position":"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/Documents/Projects/Git/CordovaPluginProcessSdk/MobileApp/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml","position":"startLine":10],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/fontVariationSettings not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/ttcIndex not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/fontVariationSettings not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
- With those errors, I've come to think that it might be an error between
cordova
andandroidx
library. To check that I've tried to add a different library (volley, which is not required for my aar library to work) with that line:
<framework src="com.android.volley:volley:1.1.1"/>
- The app builds successfully. But when I run it, it crashes once we start using elements from the AAR library. (cf. step 1)
Is Cordova compatible with androidx ? If it is, what is preventing me from using it ?
It looks like it's not compatible from the tests & errors I've got, but I haven't found relevant information on the subject on the Cordova documentation website or with a google search. So I can't confirm.
PS: I tried to be as exhaustive as possible, please ask if you're missing information.
Edit #1:
- I tried to change
androidx
back toappcompat
in my .aar library. I generated a new .aar & used
<framework src="com.android.support:appcompat-v7:28.0.0"/>
instead of the androidx import.
Result: Same as (1.) issue.
Conclusion: It might not be because of androidx
- I remembered that on the official doc of Cordova they're using an import of appcompat: Cordova - Plugin.xml - Framework. So I used this one:
<!-- Depend on v21 of appcompat-v7 support library -->
<framework src="com.android.support:appcompat-v7:21+" />
And it builds correctly. But still crashes because the function used in the .aar file doesn't exist for this version of the library.
Process: io.cordova.hellocordova, PID: 16523
java.lang.NoSuchMethodError: No static method checkSelfPermission(Landroid/content/Context;Ljava/lang/String;)I in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/io.cordova.hellocordova-2/base.apk)
If possible I would like to keep using androidx instead of appcompat because I have other modules that depend on it.
android cordova gradle plugins aar
Objective
I need to develop a plugin for Cordova that implements some code (aar file) I've already developed, for an android app.
System
- OS: Ubuntu 18.04.2 LTS
- IDEs: VSCode & Android Studio
- Phone: Nexus 4 - Android 5.1.1
- Cordova version: 8.1.2 (cordova-lib@8.1.1)
- SDK informations of the Cordova app(from build.gradle):
defaultBuildToolsVersion="27.0.1" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=27 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=27 //Integer - We ALWAYS compile with the latest by default
What I've tried
- I've made a .aar file from that project & I'm trying to add it to my Cordova plugin. I can import the methods from that project, but the application crashes once I open the activity that uses those methods (the app still builds correctly).
03-21 12:35:59.728 12235-12235/io.cordova.hellocordova E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.cordova.hellocordova, PID: 12235
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/content/ContextCompat;
- I figured it might be because of
androidx
thanks toFailed resolution of: Landroidx/core/content/ContextCompat;
. So I added that line to myplugin.xml
file:
<!-- I have the same version of androidx.appcompat in my aar library -->
<framework src="androidx.appcompat:appcompat:1.0.0-beta01"/>
- With that change the app refuses to build and I get those errors (I replaced the absolute project path with
<projectpath>
):
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values-v28/values-v28.xml","position":"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/dialogCornerRadius not found.","sources":["file":"/home/benjamin/Documents/Projects/Git/CordovaPluginProcessSdk/MobileApp/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml","position":"startLine":10],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/fontVariationSettings not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
AGPBI: "kind":"error","text":"error: resource android:attr/ttcIndex not found.","sources":["file":"/home/benjamin/.gradle/caches/transforms-1/files-1.1/appcompat-1.0.0-beta01.aar/ad380179fb375e61241b11fa4df558eb/res/values/values.xml","position":"startLine":1303,"startColumn":4,"startOffset":70911,"endColumn":68,"endOffset":70975],"original":"","tool":"AAPT"
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/fontVariationSettings not found.
<projectpath>/platforms/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:228: error: resource android:attr/ttcIndex not found.
error: failed linking references.
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
at sun.reflect.GeneratedMethodAccessor274.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
- With those errors, I've come to think that it might be an error between
cordova
andandroidx
library. To check that I've tried to add a different library (volley, which is not required for my aar library to work) with that line:
<framework src="com.android.volley:volley:1.1.1"/>
- The app builds successfully. But when I run it, it crashes once we start using elements from the AAR library. (cf. step 1)
Is Cordova compatible with androidx ? If it is, what is preventing me from using it ?
It looks like it's not compatible from the tests & errors I've got, but I haven't found relevant information on the subject on the Cordova documentation website or with a google search. So I can't confirm.
PS: I tried to be as exhaustive as possible, please ask if you're missing information.
Edit #1:
- I tried to change
androidx
back toappcompat
in my .aar library. I generated a new .aar & used
<framework src="com.android.support:appcompat-v7:28.0.0"/>
instead of the androidx import.
Result: Same as (1.) issue.
Conclusion: It might not be because of androidx
- I remembered that on the official doc of Cordova they're using an import of appcompat: Cordova - Plugin.xml - Framework. So I used this one:
<!-- Depend on v21 of appcompat-v7 support library -->
<framework src="com.android.support:appcompat-v7:21+" />
And it builds correctly. But still crashes because the function used in the .aar file doesn't exist for this version of the library.
Process: io.cordova.hellocordova, PID: 16523
java.lang.NoSuchMethodError: No static method checkSelfPermission(Landroid/content/Context;Ljava/lang/String;)I in class Landroid/support/v4/content/ContextCompat; or its super classes (declaration of 'android.support.v4.content.ContextCompat' appears in /data/app/io.cordova.hellocordova-2/base.apk)
If possible I would like to keep using androidx instead of appcompat because I have other modules that depend on it.
android cordova gradle plugins aar
android cordova gradle plugins aar
edited 2 days ago
Noxilex
asked 2 days ago
NoxilexNoxilex
163
163
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The resources that are missing (ttcIndex
etc) were only added in API 28 - that's why they're in a folder called values-v28
.
You need to update your compileSdkVersion
to 28 in order for this to compile successfully.
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
add a comment |
Thanks to this documentation Flutter Doc I migrated my project to be compatible with Androidx. (Like Android Studio would have done using the Refactor > Migrate to AndroidX
option) Yes, it's from Flutter and not Cordova, but since it's general information for any Android project, it still fits.
Main things I've done were:
- Adding a file
gradle.properties
toplatforms/android
android.enableJetifier=true
android.useAndroidX=true
- Upgrading minSdkVersion from
15
to19
- Upgrading target & compile sdkVersion from
27
to28
- Updating gradle from
3.0.0
to3.3.2
Since I created my project with Cordova CLI, I didn't think it would work like a normal Android project regarding those features, so I overlooked it.
I've ran some tests & the application seems to work OK now.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281348%2fadd-custom-aar-library-using-androidx-to-cordova-plugin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The resources that are missing (ttcIndex
etc) were only added in API 28 - that's why they're in a folder called values-v28
.
You need to update your compileSdkVersion
to 28 in order for this to compile successfully.
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
add a comment |
The resources that are missing (ttcIndex
etc) were only added in API 28 - that's why they're in a folder called values-v28
.
You need to update your compileSdkVersion
to 28 in order for this to compile successfully.
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
add a comment |
The resources that are missing (ttcIndex
etc) were only added in API 28 - that's why they're in a folder called values-v28
.
You need to update your compileSdkVersion
to 28 in order for this to compile successfully.
The resources that are missing (ttcIndex
etc) were only added in API 28 - that's why they're in a folder called values-v28
.
You need to update your compileSdkVersion
to 28 in order for this to compile successfully.
answered yesterday
Izabela OrlowskaIzabela Orlowska
4,1352722
4,1352722
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
add a comment |
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
Thanks for the contribution ! It does work now & your feedback was part of the things I changed. It's nice to have more insights on why those changes solved the problem though.
– Noxilex
yesterday
add a comment |
Thanks to this documentation Flutter Doc I migrated my project to be compatible with Androidx. (Like Android Studio would have done using the Refactor > Migrate to AndroidX
option) Yes, it's from Flutter and not Cordova, but since it's general information for any Android project, it still fits.
Main things I've done were:
- Adding a file
gradle.properties
toplatforms/android
android.enableJetifier=true
android.useAndroidX=true
- Upgrading minSdkVersion from
15
to19
- Upgrading target & compile sdkVersion from
27
to28
- Updating gradle from
3.0.0
to3.3.2
Since I created my project with Cordova CLI, I didn't think it would work like a normal Android project regarding those features, so I overlooked it.
I've ran some tests & the application seems to work OK now.
add a comment |
Thanks to this documentation Flutter Doc I migrated my project to be compatible with Androidx. (Like Android Studio would have done using the Refactor > Migrate to AndroidX
option) Yes, it's from Flutter and not Cordova, but since it's general information for any Android project, it still fits.
Main things I've done were:
- Adding a file
gradle.properties
toplatforms/android
android.enableJetifier=true
android.useAndroidX=true
- Upgrading minSdkVersion from
15
to19
- Upgrading target & compile sdkVersion from
27
to28
- Updating gradle from
3.0.0
to3.3.2
Since I created my project with Cordova CLI, I didn't think it would work like a normal Android project regarding those features, so I overlooked it.
I've ran some tests & the application seems to work OK now.
add a comment |
Thanks to this documentation Flutter Doc I migrated my project to be compatible with Androidx. (Like Android Studio would have done using the Refactor > Migrate to AndroidX
option) Yes, it's from Flutter and not Cordova, but since it's general information for any Android project, it still fits.
Main things I've done were:
- Adding a file
gradle.properties
toplatforms/android
android.enableJetifier=true
android.useAndroidX=true
- Upgrading minSdkVersion from
15
to19
- Upgrading target & compile sdkVersion from
27
to28
- Updating gradle from
3.0.0
to3.3.2
Since I created my project with Cordova CLI, I didn't think it would work like a normal Android project regarding those features, so I overlooked it.
I've ran some tests & the application seems to work OK now.
Thanks to this documentation Flutter Doc I migrated my project to be compatible with Androidx. (Like Android Studio would have done using the Refactor > Migrate to AndroidX
option) Yes, it's from Flutter and not Cordova, but since it's general information for any Android project, it still fits.
Main things I've done were:
- Adding a file
gradle.properties
toplatforms/android
android.enableJetifier=true
android.useAndroidX=true
- Upgrading minSdkVersion from
15
to19
- Upgrading target & compile sdkVersion from
27
to28
- Updating gradle from
3.0.0
to3.3.2
Since I created my project with Cordova CLI, I didn't think it would work like a normal Android project regarding those features, so I overlooked it.
I've ran some tests & the application seems to work OK now.
edited yesterday
answered 2 days ago
NoxilexNoxilex
163
163
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281348%2fadd-custom-aar-library-using-androidx-to-cordova-plugin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown