简体   繁体   中英

Android Studio not installing App on device

SOLVED IT:

It was a problem of my Phone after resetting it everything worked. Thanks to everybody that tried to help me.


I write a app in Android Studio and tested it on my device today I uninstalled it and tried to run it with Android Studio. But the app wont start and Android Studio generates the following error:

$ adb shell am start -n "de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Error while executing: am start -n "de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=de.clashbestie.pccontrol/.activities.ConnectActivity }
Error type 3
Error: Activity class {de.clashbestie.pccontrol/de.clashbestie.pccontrol.activities.ConnectActivity} does not exist.

Error while Launching activity

And a screenshot too

Yes I see the "does not exist" and yeah this is the problem, the app gets not installed, but as seeable in the screenshot Android Studio say "Install succesfully finished".

I tried clean & rebuild restarted Android Studio, my PC, and My Device. Anybody knows what I can do else?

Btw. In emulator the app gets intalled.

Here is my mainfest:

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

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

    <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=".activities.ControlActivity"
            android:label="@string/title_activity_control"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity android:name=".activities.ConnectActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

ConnectActivity.java: (Removed Imports to short it)

package de.clashbestie.pccontrol.activities;

public class ConnectActivity extends AppCompatActivity {

    private static ConnectActivity instance;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        instance = this;
    }

    public void connect(View v)  {
        findViewById(R.id.ip).clearFocus();
        findViewById(R.id.port).clearFocus();
        Button button = (Button) findViewById(R.id.connect);
        if (button.getText().equals(getString(R.string.button_connecting))) {
            Snackbar.make(instance.findViewById(R.id.connect), "Already connecting", Snackbar.LENGTH_SHORT).show();
        } else {
            button.setText(R.string.button_connecting);
            String ip = ((EditText) findViewById(R.id.ip)).getText().toString();
            String port = ((EditText) findViewById(R.id.port)).getText().toString();
            ((InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(findViewById(R.id.connect).getWindowToken(), 0);

            new ConnectorThread(ip, port).start();
        }
    }

    public static void launchControlActivity(Socket socket) {
        Button button = (Button) instance.findViewById(R.id.connect);
        button.setText(R.string.button_connect);
        try {
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
       instance.getApplicationContext().startActivity(new Intent(instance, ControlActivity.class));
    }

    public static void showConnectError(String text) {
        Button button = (Button) instance.findViewById(R.id.connect);
        button.setText(R.string.button_connect);
        Snackbar.make(instance.findViewById(R.id.connect), text, Snackbar.LENGTH_LONG).show();

    }
}

The reason why you re getting the error is because you have no activity to launch the app, so in your manifest file, you should specify the launcher activity

  • This is the code
 <activity
            android:name=".activities.ControlActivity"  activity
            android:label="@string/title_activity_control"
            android:theme="@style/AppTheme.NoActionBar"></activity>
        <activity android:name=".activities.ConnectActivity"> // here specify the the
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM