Error while Launching activity in android studio using empty activity

by Nehemiah Limo   Last Updated August 13, 2019 20:26 PM

I just made a minimal application and i have ran into a problem solving it. i get this error after running it. " Could not identify launch activity: Default Activity not found Error while Launching activity "

I tried editing the Manifest file and added the main activity package like this : "com.example.loanapplication.MainActivity " and edited the configuration and 'specified the activity' but then after running it, the same error appeared.

MainActivity

public class MainActivity extends AppCompatActivity {

    private ListView listViewLoans;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        try{
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            List<Loans> loans = new HttpRequestLoansList().execute().get();
            listViewLoans = (ListView) findViewById(R.id.listViewLoans);
            listViewLoans.setAdapter( new LoanListAdapter(loans, getApplicationContext()));
        }
        catch (Exception e){
            AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
            builder.setMessage(e.getMessage());
            builder.create().show();
        }

    }

    private  class HttpRequestLoansList extends AsyncTask<Void, Void, List<Loans>>{

        @Override
        protected List<Loans> doInBackground(Void... params) {
            LoanModel loanModel = new LoanModel();
            return  loanModel.all();
        }

        @Override
        protected void onPostExecute(List<Loans> loans) {
            super.onPostExecute(loans);
        }
    }

Manifest File

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


    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <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/AppTheme">
        <activity android:name="com.example.loanapplication.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>




    </manifest>

activity_main xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/buttonAdd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Add Loan" />

    <ListView
        android:id="@+id/listViewLoans"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

error inlclude the following: Could not identify launch activity: Default Activity not found Error while Launching activity

expectations:

Tags : android


Answers 1


Please go to Build > clean project and then build that again

noname
noname
August 13, 2019 15:03 PM

Related Questions