我有一些基于我严重修改的开源代码的动态壁纸。作为最后一项,我在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添加了前缀。我不明白的是,如果这是不正确的,那么为什么壁纸可以工作,因为服务名称的限定方式完全相同?
修改
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>
答案 0 :(得分:0)
在添加赏金后不久,我找到了解决此问题的方法。不过,我仍然不确定最初的问题是什么。
为了解决这个问题,我重命名了包含所有代码的ffvideolivewallpaper.frankandrobot.com包,以匹配清单的代码。我有点犹豫要做这个,因为它需要更新video.c文件来更改本地调用“com_nightscapecreations_anim1”中的所有“ffvideolivewallpaper_frankandrobot_com”引用,并且我最后一次尝试将我的应用程序弄得如此糟糕我不得不返回备份副本。但是,今天这样做,然后通过应用程序搜索/替换以找到所有其他引用,我能够让它工作。
尽管如此,我仍然想知道上述问题的答案。如果我可以单独保留主程序包名称而不是打扰搜索/替换,那么将来在此基础上创建新应用程序要容易得多。但是,如果没有人知道,我只会将此标记为答案。