Error Type 3 - Activity does exist

Asked

Viewed 748 times

2

Every time I try to run my app on AVD or on my phone to test the following message appears to me:

Error while executing: 
  am start -n "com.example.vantajoso/com.example.vantajoso.MainActivity" 
    -a android.intent.action.MAIN
    -c android.intent.category.LAUNCHER

Starting: Intent { 
  act=android.intent.action.MAIN
  cat=[android.intent.category.LAUNCHER]
  cmp=com.example.vantajoso/.MainActivity }

Error type 3 Error: 
  Activity class {com.example.vantajoso/com.example.vantajoso.MainActivity} 
  does not exist.

Error while Launching activity

Below follows as is my Androidmaifest.xml

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

  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

  <application android:allowBackup="true" 
    android:icon="@mipmap/iconvantajosoweb_round" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/iconvantajosoweb_round" 
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
    tools:ignore="GoogleAppIndexingWarning">


    <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <action android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

    </activity>


  </application>
</manifest>

My Mainactivity

package com.example.vantajoso;
import android.view.WindowManager;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

public class MainActivity extends AppCompatActivity {
  private WebView mWebView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //remove o titulo
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
      WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //codigo para o webview
    setContentView(R.layout.activity_main);
    WebView myWebView = (WebView) this.findViewById(R.id.webView1);
    myWebView.setWebViewClient(new WebViewClient());
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.loadUrl("https://meusite.com.br");
  }
}

Does anyone have any idea what it is?

  • It seems to me that this line <action android:name="android.intent.category.LAUNCHER" /> should be <category android:name="android.intent.category.LAUNCHER" />

  • 1

    @icaroMartins I tried here but the same error happens. I have no idea what to do :X

2 answers

2

In my case the error arose from a change in run configuration when I was trying to run in release mode. Possibly I must have put something incorrect in the configuration. I tried the possibilities given in this issue, were not acerctive, but I recommend using before my solution. My case had to delete and remake the run configuration.

For that reason:

  • Find the run configuration - similar to the image, usually named after app:

inserir a descrição da imagem aqui

Or navigating via menu Run

  • Select Edit Configuration... as the image:

inserir a descrição da imagem aqui

Or navigating via menu Run > Edit Configuration...

  • Delete existing settings (save custom parameters if they exist) and recreate.

That solved the problem.

1

When we compare your manifest to one of example of Android, to notice a difference in this line of its manifest:

<action android:name="android.intent.category.LAUNCHER" />
<!--  ^                                 ^  -->

in the example this way:

<category android:name="android.intent.category.LAUNCHER" />
<!--  ^ category                         ^  -->

This may/could be one of the problems, as we were told comments that this did not solve, the next attempt would be to clear the project cache, as explained here in this reply from Soen.

  1. Clear Project: Build -> Clear Project
  2. Delete the directory Build
  3. Restart your Android Studio
  4. Remove the Smartphone App
  5. Compile Projeto: Build -> Rebuild Project
  6. Run
  7. (optional) Invalidate cache: File -> Invalidate Caches / Restart...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.