我有一個基於關的,我沉重修改一些開源代碼的動態壁紙。作爲最後一項,我在Eclipse中右鍵單擊它以更改軟件包名稱,並且與世界一切都很好。壁紙正常工作。設置菜單正常工作。但是,當我試着在設置菜單中單擊某個項目啓動另一個活動,我得到:Android的重命名:無法找到明確的活動類
10-10 16:16:56.215: E/AndroidRuntime(13825): FATAL EXCEPTION: main
10-10 16:16:56.215: E/AndroidRuntime(13825): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.nightscapecreations.orionkeysfree/ffvideolivewallpaper.frankandrobot.com.extLinkNC}; have you declared this activity in your AndroidManifest.xml?
這裏是清單文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nightscapecreations.anim1"
android:versionCode="1"
android:versionName="0.9.0" >
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9" />
<!-- Tell the system this app requires OpenGL ES 2.0. -->
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-feature android:name="android.software.live_wallpaper" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<service
android:name="ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper"
android:label="@string/wallpaper"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/wallpaper" />
</service>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.VideoLiveWallpaper"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.VideoWallpaperSettings"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.About"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.License"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.SelectVideo"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.extLinkNC"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.extLinkZazzle"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.extLinkFacebook"
android:exported="true"
android:label="@string/app_name" >
</activity>
<activity
android:name="ffvideolivewallpaper.frankandrobot.com.extLinkGooglePlus"
android:exported="true"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
這裏是關於活動,作爲一個例子,這是確認工作之前這種變化:
package ffvideolivewallpaper.frankandrobot.com;
import android.app.Activity;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import android.content.Intent;
import android.view.View;
import com.nightscapecreations.anim1.R;
public class About extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
TextView t = (TextView) findViewById(R.id.about_box);
t.setMovementMethod(LinkMovementMethod.getInstance());
}
public void showLicense(View view) {
startActivity(new Intent(About.this, License.class));
}
}
ffvideolivewallpaper.frankandrobot.com是舊的軟件包名稱。 Eclipse在包名稱更改期間爲所有活動的android:name添加了前綴。我不明白的是,如果這是不正確的,那麼爲什麼壁紙可以工作,因爲服務名稱是完全相同的方式?
編輯
詞dunamis做出了卓越的捕獲。最初的名字是 ffvideolivewallpaper.frankandrobot.com,但自那時以來,它一直在通過多次名稱更改。一個這樣的名字是com.nightscapecreations.orionkeysfree。它看起來仍然是一個對舊名稱的引用,我完全錯過了設置xml文件。例如:
<PreferenceCategory android:title="Links and Information" >
<PreferenceScreen android:title="Visit Nightscape Creations"
android:summary="See more live wallpapers, get free static wallpapers, and learn about NC by visiting us online." >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.extLinkNC"
android:targetPackage="com.nightscapecreations.orionkeysfree" />
</PreferenceScreen>
但是,這仍然不起作用。我在本文件和清單文件之間嘗試了全限定名稱和簡單點符號「.extLinkFacebook」的所有組合,但沒有成功。這是我與這兩個名字完全合格的,現在收到的錯誤:
10-11 08:19:43.176: E/AndroidRuntime(25204): FATAL EXCEPTION: main
10-11 08:19:43.176: E/AndroidRuntime(25204): android.content.ActivityNotFoundException: Unable to find explicit activity class {ffvideolivewallpaper.frankandrobot.com/ffvideolivewallpaper.frankandrobot.com.extLinkFacebook}; have you declared this activity in your AndroidManifest.xml?
下面是引用設置文件:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Wallpaper Settings">
<ffvideolivewallpaper.frankandrobot.com.PrefsSlider
android:key="fps"
android:title="Framerate"
android:summary="Set the target framerate. Lower framerates will decrease resource usage. Requires wallpaper restart to take effect."
android:layout_width="fill_parent"
android:defaultValue="30"
android:orientation="vertical" />
<!-- <ListPreference -->
<!-- android:enabled="true" -->
<!-- android:key="resolution" -->
<!-- android:title="Resolution" -->
<!-- android:summary="Ultra resolution may decrease framerate. Only recommended for high end devices." -->
<!-- android:entries="@array/prefs_resolutionEntries" -->
<!-- android:entryValues="@array/prefs_resolutionValues" -->
<!-- android:defaultValue="512" /> -->
<!-- <ListPreference -->
<!-- android:enabled="true" -->
<!-- android:key="frameTonality" -->
<!-- android:title="Filters" -->
<!-- android:summary="Various effects and filters can be applied to the animation" -->
<!-- android:entries="@array/prefs_tonalityEntries" -->
<!-- android:entryValues="@array/prefs_tonalityValues" -->
<!-- android:defaultValue="1" /> -->
</PreferenceCategory>
<PreferenceCategory android:title="Links and Information" >
<PreferenceScreen android:title="Visit Nightscape Creations"
android:summary="See more live wallpapers, get free static wallpapers, and learn about NC by visiting us online." >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.extLinkNC"
android:targetPackage="ffvideolivewallpaper.frankandrobot.com" />
</PreferenceScreen>
<PreferenceScreen
android:title="@string/prefsProductsHeading"
android:summary="@string/prefsProductsSummary" >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.extLinkZazzle"
android:targetPackage="ffvideolivewallpaper.frankandrobot.com" />
</PreferenceScreen>
<PreferenceScreen android:title="Like on Facebook" >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.extLinkFacebook"
android:targetPackage="ffvideolivewallpaper.frankandrobot.com" />
</PreferenceScreen>
<PreferenceScreen android:title="Like on Google+" >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.extLinkGooglePlus"
android:targetPackage="ffvideolivewallpaper.frankandrobot.com" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="About" >
<PreferenceScreen android:title="About" >
<intent
android:targetClass="ffvideolivewallpaper.frankandrobot.com.About"
android:targetPackage="ffvideolivewallpaper.frankandrobot.com" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
刪除活動名稱的前綴,只需使用'.VideoLiveWallpaper'。注意點前綴。 – Simon
視頻動態壁紙活動正常工作。這是其他問題。這是奇怪的部分。 – Nicholas
這只是一個例子。你應該爲所有活動做到這一點。 – Simon