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

1.5k Views Asked by At

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

2

There are 2 best solutions below

0
Arjun T Raj On BEST ANSWER

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

1
sorenoid On

This worked for me as a short term solution:

it is most likely failing this if statement at platforms/android/cordova/Api.js:82 You can comment it out to test and to get a build. for whatever reason your android build still thinks it is the old style build.

    // XXX Override some locations for Android Studio projects                                                                               
if (AndroidStudio.isAndroidStudioProject(self.root) === true) {
    selfEvents.emit('log', 'Android Studio project detected');
    this.builder = 'studio';
    this.android_studio = true;
    this.locations.configXml = path.join(self.root, 
    'app/src/main/res/xml/config.xml');
    this.locations.strings = path.join(self.root, 
    'app/src/main/res/values/strings.xml');
    this.locations.manifest = path.join(self.root, 
    'app/src/main/AndroidManifest.xml');
    // We could have Java Source, we could have other languages                                                                          
    this.locations.javaSrc = path.join(self.root, 'app/src/main/java/');
    this.locations.www = path.join(self.root, 'app/src/main/assets/www');
    this.locations.res = path.join(self.root, 'app/src/main/res');
}