我是Android开发的新手试图制作应用程序(计算器)但由于以下错误而无法启动应用程序:
Error while executing: am start -n "apper.com.calc1/apper.com.calc1.StartActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=apper.com.calc1/.StartActivity }
Error type 3
Error: Activity class {apper.com.calc1/apper.com.calc1.StartActivity} does not exist.
Error while Launching activity
这是Android清单文件,
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="apper.com.calc1">
<application
android:icon="@mipmap/ic_launcher_calculator"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:theme="@style/CalculatorTheme">
<activity
android:name=".StartActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.APP_CALCULATOR" />
</intent-filter>
</activity>
<activity
android:name=".CalculatorL"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" />
</application>
StartActivity.java
package com.apper.calc1;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class StartActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Utils.hasLollipop()) {
startActivity(new Intent(this, CalculatorL.class));
} else {
startActivity(new Intent(this, CalculatorGB.class));
}
finish();
}
}
答案 0 :(得分:0)
包是:
package="apper.com.calc1"
但在你的StartActivity中是:
package com.apper.calc1;
尝试修改它
答案 1 :(得分:0)
Log cat Error表示项目中没有apper.com.calc1.StartActivity
,这是真的。你拥有的是com.apper.calc1.StartActivity
。
尝试将清单中的软件包名称更改为像Mike提到的com.apper.calc1
,或者使用软件包名称还原您之前所做的更改。