2013-10-10 155 views
1

我有一個基於關的,我沉重修改一些開源代碼的動態壁紙。作爲最後一項,我在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> 
+0

刪除活動名稱的前綴,只需使用'.VideoLiveWallpaper'。注意點前綴。 – Simon

+0

視頻動態壁紙活動正常工作。這是其他問題。這是奇怪的部分。 – Nicholas

+0

這只是一個例子。你應該爲所有活動做到這一點。 – Simon

回答

0

加入賞金後不久,我發現了這個問題的解決方法。不過,我仍然不確定最初的問題是什麼。

要解決此我改名爲ffvideolivewallpaper.frankandrobot.com包,它包含了所有的代碼,以匹配清單的。我曾猶豫過要做到這一點,因爲它需要更新到VIDEO.C文件更改爲「com_nightscapecreations_anim1」本地調用所有「ffvideolivewallpaper_frankandrobot_com」引用上次我試過,我在該區的應用程序如此糟糕,我不得不返回備份副本。但是,今天這樣做之後,然後通過應用程序搜索/替換以找到所有其他參考,我就能夠使其工作。

我還是想知道答案對上述問題的,因爲它主張,雖然。如果我可以只留下主包名稱而不是打擾搜索/替換,那麼將來在此基礎上創建新應用會容易得多。但是,如果沒有人知道,我會將其標記爲答案。

相關問題