0

I am trying to automate an APK using the Appium framework.

I'm getting the below error:

> Exception occurred while executing 'start':
> [debug] [W3C] java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.pnr.engproverbsandsayings/.EngProverbsActivity } from null (pid=10400, uid=2000) not exported from uid 10151
> [debug] [W3C]     at com.android.server.wm.ActivityTaskSupervisor.checkStartAnyActivityPermission(ActivityTaskSupervisor.java:1047)
> [debug] [W3C]     at com.android.server.wm.ActivityStarter.executeRequest(ActivityStarter.java:975)
> [debug] [W3C]     at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:665)
> [debug] [W3C]     at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(ActivityTaskManagerService.java:1441)
> [debug] [W3C]     at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:2935)

Java code for execution:

AppiumDriver<MobileElement> driver = null;
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

desiredCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");
desiredCapabilities.setCapability("appPackage", "com.pnr.engproverbsandsayings");
desiredCapabilities.setCapability("appActivity", "com.pnr.engproverbsandsayings.EngProverbsActivity");
    
try {
    URL url = new URL("http://127.0.0.1:4723/wd/hub");
    driver = new AndroidDriver<MobileElement>(url, desiredCapabilities);
    System.out.println("Appium started");
} catch (Exception e) {
    System.out.println(e.getMessage());
}

AndriodManifest.xml file is as follows:

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.MyApplication.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Tried multiple solutions from stackoverflow but nothing is working Android: java.lang.SecurityException: Permission Denial: start Intent

Amal K
  • 4,359
  • 2
  • 22
  • 44
Steve
  • 1
  • 1
  • You are missing some required capabilities like `appium:automationName` and capabilities regarding the device information you want the automation to run for, like `appium:deviceName`. You can check more [here](https://appium.io/docs/en/2.0/guides/caps/) – ChrisMersi Jul 15 '23 at 18:58
  • After doing a lot of research, the problem was with apk I was using. Tried with new apk and it worked https://m.apkpure.com/automation-sample/com.dgotlieb.automationsample – Steve Jul 16 '23 at 07:52

0 Answers0