当前位置: 代码迷 >> 综合 >> 解决 Application package 'AndroidManifest xml' must have a min
  详细解决方案

解决 Application package 'AndroidManifest xml' must have a min

热度:45   发布时间:2024-01-13 08:11:07.0
解决: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>

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

  相关解决方案