Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

java - 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();

    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...