![](/img/trans.png)
[英]“zipAlignExe' does not exist.” error while running my project on Android Studio
[英]Error while excuting Android Project "Activity class does not exist."
我在 Eclipse 中創建了示例 android 項目,但是在執行時出現錯誤:活動 class {com.example.best/com.example.best.MainActivity}
但是項目中存在 MainActivity class
package com.example.best;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
以下是控制台上打印的錯誤信息
[2015-03-01 22:01:58 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:01:59 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:02 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:02 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:05 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:05 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:08 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:08 - best] New package not yet registered with the system. Waiting 3 seconds before next attempt.
[2015-03-01 22:02:11 - best] Starting activity com.example.best.MainActivity on device EAAZCY30C637
[2015-03-01 22:02:12 - best] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.best/.MainActivity }
[2015-03-01 22:02:12 - best] ActivityManager: Error type 3
[2015-03-01 22:02:12 - best] ActivityManager: Error: Activity class {com.example.best/com.example.best.MainActivity} does not exist.
這是我的清單文件的內容
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.best"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.best.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我應該怎么做才能解決這個問題
您的樣本沒有錯誤。 我已經在我的機器上測試了它並且它正常工作。
請嘗試以下程序。 項目 - >清潔
如果它不起作用,請嘗試創建新工作區 。
每當在應用程序中添加新活動時,都需要將其添加到清單文件中以及新標記。 確保您正在執行此操作,否則將不會考慮新活動。
好吧,我不能在您的樣本中出現任何錯誤。 我創建了一個與您的包名相同的演示項目,粘貼了完整的清單以及MainActivity,它正在我的工作中。
如果您的目標設備當前處於安全模式,這也可能會發生這種情況,這會阻止它運行來自第三方的活動。
在這種情況下,只需重新啟動設備即可禁用安全模式。
https://www.digitaltrends.com/mobile/how-to-turn-safe-mode-on-and-off-in-android/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.