我有一个基于我大量修改的一些开源代码的动态壁纸。 作为最后一项,我在 Eclipse 中右键单击它以更改包名称,世界一切都很好。 墙纸工作正常。 设置菜单工作正常。 但是当我尝试单击设置菜单中的项目以启动另一个活动时,我得到:
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 添加了前缀。 我不明白的是,如果这是不正确的,那么为什么墙纸可以工作,因为服务名称以完全相同的方式限定?
编辑
杜纳米斯做出了一个很好的收获。 原名是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>
添加赏金后不久,我找到了解决此问题的方法。 不过,我仍然不确定最初的问题是什么。
为了解决这个问题,我重命名了包含所有代码的 ffvideolivewallpaper.frankandrobot.com 包,以匹配清单的代码。 我一直犹豫要不要这样做,因为它需要更新 video.c 文件才能将本机调用中的所有"ffvideolivewallpaper_frankandrobot_com"引用更改为"com_nightscapecreations_anim1",并且上次我尝试过时,我把应用程序灌得很糟糕,我不得不返回备份副本。 但是,在今天这样做之后,然后通过应用程序搜索/替换以查找所有其他参考资料,我能够让它工作。
不过,我仍然想知道上述问题的答案。 如果我可以只保留主包名称而不是为搜索/替换而烦恼,那么将来在此基础上创建新应用程序会容易得多。 但是,如果没有人知道,我将把这个标记为答案。