Java ActivityNotFoundException:但活动已在清单中声明
希望得到一些帮助。我收到一个错误: 04-13 15:01:45.336:E/AndroidRuntime(11065): android.content.ActivityNotFoundException: 找不到显式活动类{com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity}; 您是否在AndroidManifest.xml中声明了此活动? 然而,我已经在清单中声明了类RunActivity。但是,我注意到路径不正确,它应该调用com.domakecreatedesign.runtracker.RunActivity,但是从上面可以看到,它正在调用:com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity 我不知道这是为什么。 这是我的清单xmlJava ActivityNotFoundException:但活动已在清单中声明,java,android,manifest,activitynotfoundexception,Java,Android,Manifest,Activitynotfoundexception,希望得到一些帮助。我收到一个错误: 04-13 15:01:45.336:E/AndroidRuntime(11065): android.content.ActivityNotFoundException: 找不到显式活动类{com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity}; 您是否在AndroidManifest.xml中声明了此活动? 然而,我已经在清单中声明了类RunActivity
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domakecreatedesign.getfit"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="19" />
<permission
android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.domakecreatedesign.getfit.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.GET_ACCOUNTS"
android:maxSdkVersion="19" />
<uses-permission
android:name="android.permission.USE_CREDENTIALS"
android:maxSdkVersion="19" />
<uses-feature
android:name="android.hardware.location.gps"
android:required="true" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/getfit_icon"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- Splash screen -->
<activity
android:name="com.domakecreatedesign.getfit.SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Main Activity -->
<activity
android:name="com.domakecreatedesign.getfit.MainActivity"
android:label="@string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.ChooseLogin"
android:label="@string/title_activity_fblogin" />
<activity
android:name="com.domakecreatedesign.getfit.gplus_Login"
android:label="@string/app_name" />
<activity
android:name="com.domakecreatedesign.getfit.Main_Menu"
android:label="@string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunListActivity"
android:label="@string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunMapActivity"
android:label="@string/app_name" />
<activity
android:name="com.domakecreatedesign.runtracker.RunActivity"
android:label="@string/app_name" />
<receiver
android:name=".TrackingLocationReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.domakecreatedesign.runtracker.ACTION_LOCATION" />
</intent-filter>
</receiver>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyATK_V5Ae2g7uJQM1EBhEcPZAL19B8jBuc" />
</application>
</manifest>
同样值得注意的是,该应用程序包含在两个包中
非常感谢尝试ActivityName.this而不是
getActivity()
像这样的,
Intent i = new Intent(AcitivityName.this, com.domakecreatedesign.runtracker.RunActivity.class);
试试这个
Intent i = new Intent();
i.setComponent(new ComponentName("com.domakecreatedesign.getfit", "com.domakecreatedesign.runtracker.RunActivity"));
startActivity(i);
... 假设你已经清理了你的项目并试图重建…?我不相信这个意图是错误的;我希望intent的包部分是apk的包,而其中的组件是定义活动的Java文件的包。此目标活动是否有任何在链接时可能无法满足的依赖项?你能把代码的开头贴出来吗?也可以考虑将该活动复制到它自己的包名的测试项目中,并查看它是否在那里独立工作。@ USER 30764。如果您使用ProGug,则需要为扩展活动和其他Android组件的类添加异常。(RunActivity.this,com.domakecreatedesign.runtracker.RunActivity.class)但收到一个错误:在作用域中无法访问RunActivity类型的封闭实例…我写的是否正确?谢谢我想如果我能找出请求路径不正确的原因,这将解决问题。在一个应用程序中使用两个包没有问题,我有一个类似的应用程序,工作正常,请仔细检查您的程序包名称和导入语句。如果没有问题,请向我们显示更多的错误详细信息和代码。谢谢…刚刚尝试过…返回错误:04-13 17:09:59.869:E/AndroidRuntime(9729):Process:com.domakecreatedesign.getfit,PID:9729 04-13 17:09:59.869:E/AndroidRuntime(9729):java.lang.RuntimeException:无法启动活动组件信息{com.domakecreatedesign.getfit/com.domakecreatedesign.runtracker.RunActivity}:java.lang。NullPointerException@user3076493我真的认为问题在于清单中声明的根包是:并且请求的活动位于不同的包中…是否有特殊的方法在清单文件中声明多个包?@user3076493无需更改。在您尝试使用“我的代码”之后,您会遇到不同的错误。@user3076493然后出现
RunActivity.java中的null
Intent i = new Intent(AcitivityName.this, com.domakecreatedesign.runtracker.RunActivity.class);
Intent i = new Intent();
i.setComponent(new ComponentName("com.domakecreatedesign.getfit", "com.domakecreatedesign.runtracker.RunActivity"));
startActivity(i);