解決:Application package ‘AndroidManifest.xml’ must have a minimum of 2 segments.

來源:互聯網
上載者:User
解決:Application package 'AndroidManifest.xml' must have a minimum of 2 segments.
在移植J2ME API測試專案時,一直碰到一個問題得不到解決就是AndroidManifest.xml下的package參數值問題,在Android開發環境中要求package包名必須是二級以上否則編譯時間
Application package 'AndroidManifest.xml' must have a minimum of 2 segments.這個問題一直讓我頭疼,因為大量J2ME項目中其主類可能只是一級包名,剛開始只能忍著利用Eclipse重構包名,還好這個方便
可畢竟只能治標不治本,後來想到一個方法:先寫個啟動的有二級包名的主Activity,然後利用Intent機制在這個Activity去啟動另外一個,理論上是通的,可是繞來繞去有回到了這個package參數值問題,因為測
試中發現要想通Intent成功啟動另外一個Activity,首先必須在AndroidManifest.xml(可以本應用的也可以是另外一個應用的)下定義這個Activity,如果你不定義那就去見一大堆的:
ERROR/AndroidRuntime(1550): android.content.ActivityNotFoundException: Unable to find explicit activity class {finger.mobeasy/test.cjm.Report}; have you declared this activity in your AndroidManifest.xml?
後來實在沒招:就硬硬生生的在AndroidManifest.xml定義了全名Activity沒想OK了,原來其實可以這樣定義,只能怪自己理解有誤,沒仔細看API文檔:摘自android API中NativeActivity介紹

A typical manifest would look like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.native_activity"
        android:versionCode="1"
        android:versionName="1.0">

    <!-- This is the platform API where NativeActivity was introduced. -->
    <uses-sdkandroid:minSdkVersion="8"/>

    <!-- This .apk has no Java code itself, so set hasCode to false. -->
    <applicationandroid:label="@string/app_name"android:hasCode="false">

        <!-- Our activity is the built-in NativeActivity framework class.
             This will take care of integrating with our NDK code. -->
        <activityandroid:name="android.app.NativeActivity"
                android:label="@string/app_name"
                android:configChanges="orientation|keyboardHidden">
            <!-- Tell NativeActivity the name of or .so -->
            <meta-dataandroid:name="android.app.lib_name"
                    android:value="native-activity"/>
            <intent-filter>
                <actionandroid:name="android.intent.action.MAIN"/>
                <categoryandroid:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.