解决:Application package 'AndroidManifest.xml' must have a minimum of 2 segments.

来源:互联网 发布:sass node.js 编辑:程序博客网 时间:2024/05/18 02:20
解决: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-sdk android:minSdkVersion="8" />

    <!-- This .apk has no Java code itself, so set hasCode to false. -->
    <application android: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. -->

        <activity android:name="android.app.NativeActivity"
                android:label="@string/app_name"
                android:configChanges="orientation|keyboardHidden">
            <!-- Tell NativeActivity the name of or .so -->
            <meta-data android:name="android.app.lib_name"
                    android:value="native-activity" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

原创粉丝点击