Search code examples
cordovaionic-frameworkcordova-pluginscordova-clicordova-android

Unable to install custom cordova plugin to android platform after updating to cordova android 7.0.0


I have created one cordova plugin and it was working fine with old cordova android versions (< 7.0.0). once i updated to cordova-android 7.0.0 from cli am unable to install my plugin even after updating plugin.xml based on cordova blog.

i can able to install some other plugins even those having cordova android 7 dependency. and tried both the options

<config-file target="app/src/main/AndroidManifest.xml" parent="/manifest/application">

and

<config-file target="AndroidManifest.xml" parent="/manifest/application">

UPDATE

if i remove my custom build.gradle

<framework src="src/android/abcPlugin.gradle" custom="true" type="gradleReference" />

its working..

This is the error am getting with my custom build.gradle .

cordova plugin add ../cordova-plugin-abc --save
Installing "cordova-plugin-abc" for android

Android Studio project detected

Error during processing of action! Attempting to revert...

Failed to install 'cordova-plugin-abc': Error: Uh oh!
ENOENT: no such file or directory, open '/Users/arjuntraj/Documents/abc/platforms/android/AndroidManifest.xml'

enter image description here

Ionic,Cordova info

enter image description here

Plugin.xml

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
        xmlns:android="http://schemas.android.com/apk/res/android"
        id="cordova-plugin-abc" 
        version="1.0.1">

    <name>CordovaPluginabc</name>
    <description>abc POC</description>
    <license>MIT</license>
    <keywords>ID</keywords>
    <author>  Team  </author>

    <engines>
        <engine name="cordova" version=">=7.0.0" />
        <engine name="cordova-android" version=">=7.0.0" />
    </engines>   

    <js-module src="www/abc.js" name="CordovaPluginabc">
        <clobbers target="cordova.plugins.abc" />
    </js-module>

    <!-- android -->
    <platform name="android">

        <config-file target="res/xml/config.xml" parent="/*">
            <feature name="CordovaPluginabc">
                <param name="android-package" value="com.abc.CordovaPluginabc" />
            </feature>
        </config-file>


        <config-file target="app/src/main/AndroidManifest.xml" parent="/manifest/application">
            <activity android:name="com.abc.sdk.AbcActivity">
            </activity>
        </config-file>

           <source-file src="src/android/abc/abc-sdk-v1.aar" target-dir="libs" framework="true" />    

        <source-file src="src/android/com/abc/CordovaPluginabc.java" target-dir="app/src/main/java/com/abc" />

        <framework src="src/android/abcPlugin.gradle" custom="true" type="gradleReference" />

    </platform>



</plugin>

Folder structure

enter image description here


Solution

  • Fixed by updating target for the two files.

    for aar lib file :

    target-dir="app/src/main/libs"

    and for java file :

    target-dir="src/com/abc"

    <source-file src="src/android/abc/abc.aar" target-dir="app/src/main/libs" framework="true" />
    <source-file src="src/android/com/abc/CordovaPluginAABC.java" target-dir="src/com/rak/abc" />
    

    and gradle extension also working fine without any chnage