我一直在遵循this教程来创建Android游戏。我下载了他提供的骨架,但将我的一个包从
robotgame
更改为 highst
。每当我尝试将带有示例代码的应用程序部署到我的设备时,我都会收到以下错误。
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.ronyo.robotgame/com.ronyo.highst.Loader }
Error type 3
Error: Activity class {com.ronyo.robotgame/com.ronyo.highst.Loader} does not exist.
我在我的项目中搜索了
robotgame
的实例,但找不到它的实例。上面的教程是使用 Eclipse 创建的,我将其移植到 Android Studio。我想知道我在切换 IDE 时是否忽略了一些东西?
这是我的AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ronyo.highst"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:icon="@drawable/icon"
android:label="Loader" >
<activity
android:name=".Loader"
android:configChanges="keyboard|keyboardHidden|orientation"
android:label="Loader"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.inten.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
删除文件夹 .idea 和 .gradle,然后单击按钮“将项目与 gradle 文件同步”
看起来软件包并没有到处更新。您更改了清单中的任何内容吗?
在AndroidManifest.xml文件中,在
<manifest
标签中,应该有一个package属性。需要更新以匹配您的新包名称,com.ronyo.highst
。
查看此处的文档:http://developer.android.com/guide/topics/manifest/manifest-element.html
不要直接更改它,它不会更新所有引用,使用这个
右键单击项目 > Android 工具 > 重命名应用程序包
更新模块build.gradle
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id ("kotlin-parcelize")
id ("androidx.navigation.safeargs.kotlin")
id ("dagger.hilt.android.plugin")
id ("com.google.gms.google-services")
id ("kotlin-android")
id ("kotlin-kapt")
}
android {
namespace = "net.mdev.shopping"
compileSdk = 34