j3k0 / cordova-plugin-openwith

Get your Cordova App in the O.S. "Share" menu on iOS and Android
MIT License
138 stars 114 forks source link

`cordova run android` failed with error: 'unkonwn element <uses-permission> found' #19

Closed DingDean closed 6 years ago

DingDean commented 6 years ago

Hi there,

Fresh cordova app, installed with only cordova-plugin-openwith by the command line: cordova plugin add cc.fovea.cordova.openwith --variable ANDROID_MIME_TYPE="*/*" When cordova run android, the following error is thrown:

/Projects/my-cordova/platforms/android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:49: error: unknown element \<uses-permission> found. 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.GeneratedMethodAccessor412.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)

After poking around, I removed the following lines from platfoms/android/android.json:

       {
         "xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />",
         "count": 1
       },`

and moved the line in the file 'platforms/android/app/src/main/AndroidManifest.xml' \<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

from within the \<application> to directly above the \<application> tag, so now the file becomes:

\<?xml version='1.0' encoding='utf-8'?> \<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android"> \<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> \<uses-permission android:name="android.permission.INTERNET" /> \<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> \<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true"> \<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTask" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize"> \<intent-filter android:label="@string/launcher_name"> \<action android:name="android.intent.action.MAIN" /> \<category android:name="android.intent.category.LAUNCHER" /> \</intent-filter> \<intent-filter> \<data android:mimeType="/" /> \<action android:name="android.intent.action.SEND" /> \<category android:name="android.intent.category.DEFAULT" /> \</intent-filter> \</activity> \</application> \<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" /> \</manifest>

Then, cordova run android succeeded again, and I can see the cordova app in the 'share to' panel.

Now I'm totally new to android and cordova, please correct me if this is a false issue. Thanks.

dickverweij commented 6 years ago

I have the same issue.

dominikgyecsek commented 6 years ago

Same here

j3k0 commented 6 years ago

PR #3 fixed this but wasn't released yet. I now released version 1.1.1 which includes the fix.